@@ -67,7 +67,7 @@ impl Ascii {
67
67
/// Check if the character is a number (0-9)
68
68
#[ inline]
69
69
pub fn is_digit ( & self ) -> bool {
70
- self . chr >= 0x31 && self . chr <= 0x39
70
+ self . chr >= 0x30 && self . chr <= 0x39
71
71
}
72
72
73
73
/// Check if the character is a letter or number
@@ -85,7 +85,7 @@ impl Ascii {
85
85
/// Check if the character is a control character
86
86
#[ inline]
87
87
pub fn is_control ( & self ) -> bool {
88
- self . chr <= 0x20 || self . chr == 0x7F
88
+ self . chr < 0x20 || self . chr == 0x7F
89
89
}
90
90
91
91
/// Checks if the character is printable (except space)
@@ -498,6 +498,15 @@ mod tests {
498
498
assert_eq ! ( '`' . to_ascii( ) . to_upper( ) . to_char( ) , '`' ) ;
499
499
assert_eq ! ( '{' . to_ascii( ) . to_upper( ) . to_char( ) , '{' ) ;
500
500
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
+
501
510
assert ! ( "banana" . chars( ) . all( |c| c. is_ascii( ) ) ) ;
502
511
assert ! ( !"ประเทศไทย中华Việt Nam" . chars( ) . all( |c| c. is_ascii( ) ) ) ;
503
512
}
0 commit comments