@@ -67,7 +67,7 @@ impl Ascii {
6767 /// Check if the character is a number (0-9)
6868 #[ inline]
6969 pub fn is_digit ( & self ) -> bool {
70- self . chr >= 0x31 && self . chr <= 0x39
70+ self . chr >= 0x30 && self . chr <= 0x39
7171 }
7272
7373 /// Check if the character is a letter or number
@@ -85,7 +85,7 @@ impl Ascii {
8585 /// Check if the character is a control character
8686 #[ inline]
8787 pub fn is_control ( & self ) -> bool {
88- self . chr <= 0x20 || self . chr == 0x7F
88+ self . chr < 0x20 || self . chr == 0x7F
8989 }
9090
9191 /// Checks if the character is printable (except space)
@@ -498,6 +498,15 @@ mod tests {
498498 assert_eq ! ( '`' . to_ascii( ) . to_upper( ) . to_char( ) , '`' ) ;
499499 assert_eq ! ( '{' . to_ascii( ) . to_upper( ) . to_char( ) , '{' ) ;
500500
501+ assert ! ( '0' . to_ascii( ) . is_digit( ) ) ;
502+ assert ! ( '9' . to_ascii( ) . is_digit( ) ) ;
503+ assert ! ( !'/' . to_ascii( ) . is_digit( ) ) ;
504+ assert ! ( !':' . to_ascii( ) . is_digit( ) ) ;
505+
506+ assert ! ( ( 0x1fu8 ) . to_ascii( ) . is_control( ) ) ;
507+ assert ! ( !' ' . to_ascii( ) . is_control( ) ) ;
508+ assert ! ( ( 0x7fu8 ) . to_ascii( ) . is_control( ) ) ;
509+
501510 assert ! ( "banana" . chars( ) . all( |c| c. is_ascii( ) ) ) ;
502511 assert ! ( !"ประเทศไทย中华Việt Nam" . chars( ) . all( |c| c. is_ascii( ) ) ) ;
503512 }
0 commit comments