@@ -544,13 +544,13 @@ fn consume_unicode_range(tokenizer: &mut Tokenizer) -> ComponentValue {
544544 question_marks += 1 ;
545545 tokenizer. position += 1
546546 }
547- let start: char ;
548- let end: char ;
547+ let start;
548+ let end;
549549 if question_marks > 0 {
550- start = char_from_hex ( hex + "0" . repeat ( question_marks) ) ;
551- end = char_from_hex ( hex + "F" . repeat ( question_marks) ) ;
550+ start = u32 :: from_str_radix ( hex + "0" . repeat ( question_marks) , 16 ) . unwrap ( ) ;
551+ end = u32 :: from_str_radix ( hex + "F" . repeat ( question_marks) , 16 ) . unwrap ( ) ;
552552 } else {
553- start = char_from_hex ( hex) ;
553+ start = u32 :: from_str_radix ( hex, 16 ) . unwrap ( ) ;
554554 hex = ~"";
555555 if !tokenizer. is_eof ( ) && tokenizer. current_char ( ) == '-' {
556556 tokenizer. position += 1 ;
@@ -563,21 +563,12 @@ fn consume_unicode_range(tokenizer: &mut Tokenizer) -> ComponentValue {
563563 }
564564 }
565565 }
566- end = if hex. len ( ) > 0 { char_from_hex ( hex) } else { start }
567- }
568- if start > MAX_UNICODE || end < start {
569- EmptyUnicodeRange
570- } else {
571- let end = if end <= MAX_UNICODE { end } else { MAX_UNICODE } ;
572- // UnicodeRange {start: start, end: end}
573- UnicodeRange ( start, end)
566+ end = if hex. len ( ) > 0 { u32:: from_str_radix ( hex, 16 ) . unwrap ( ) } else { start }
574567 }
568+ UnicodeRange { start : start, end : end}
575569}
576570
577571
578- static MAX_UNICODE : char = ' \U 0010 FFFF ' ;
579-
580-
581572// Assumes that the U+005C REVERSE SOLIDUS (\) has already been consumed
582573// and that the next input character has already been verified
583574// to not be a newline.
@@ -602,16 +593,11 @@ fn consume_escape(tokenizer: &mut Tokenizer) -> char {
602593 _ => ( )
603594 }
604595 }
605- let c = char_from_hex ( hex) ;
596+ let c = u32:: from_str_radix ( hex, 16 ) . unwrap ( ) as char as char ;
597+ static MAX_UNICODE : char = ' \U 0010 FFFF ' ;
606598 if '\x00' < c && c <= MAX_UNICODE { c }
607599 else { '\uFFFD' } // Replacement character
608600 } ,
609601 c => c
610602 }
611603}
612-
613-
614- #[ inline]
615- fn char_from_hex ( hex : & str ) -> char {
616- u32:: from_str_radix ( hex, 16 ) . unwrap ( ) as char
617- }
0 commit comments