@@ -20,7 +20,13 @@ use tables::{derived_property, property, general_category, conversions, charwidt
20
20
21
21
/// Returns whether the specified `char` is considered a Unicode alphabetic
22
22
/// code point
23
- pub fn is_alphabetic ( c : char ) -> bool { derived_property:: Alphabetic ( c) }
23
+ pub fn is_alphabetic ( c : char ) -> bool {
24
+ match c {
25
+ 'a' .. 'z' | 'A' .. 'Z' => true ,
26
+ c if c > '\x7f' => derived_property:: Alphabetic ( c) ,
27
+ _ => false
28
+ }
29
+ }
24
30
25
31
/// Returns whether the specified `char` satisfies the 'XID_Start' Unicode property
26
32
///
@@ -44,15 +50,27 @@ pub fn is_XID_continue(c: char) -> bool { derived_property::XID_Continue(c) }
44
50
/// This is defined according to the terms of the Unicode Derived Core Property 'Lowercase'.
45
51
///
46
52
#[ inline]
47
- pub fn is_lowercase ( c : char ) -> bool { derived_property:: Lowercase ( c) }
53
+ pub fn is_lowercase ( c : char ) -> bool {
54
+ match c {
55
+ 'a' .. 'z' => true ,
56
+ c if c > '\x7f' => derived_property:: Lowercase ( c) ,
57
+ _ => false
58
+ }
59
+ }
48
60
49
61
///
50
62
/// Indicates whether a `char` is in upper case
51
63
///
52
64
/// This is defined according to the terms of the Unicode Derived Core Property 'Uppercase'.
53
65
///
54
66
#[ inline]
55
- pub fn is_uppercase ( c : char ) -> bool { derived_property:: Uppercase ( c) }
67
+ pub fn is_uppercase ( c : char ) -> bool {
68
+ match c {
69
+ 'A' .. 'Z' => true ,
70
+ c if c > '\x7f' => derived_property:: Uppercase ( c) ,
71
+ _ => false
72
+ }
73
+ }
56
74
57
75
///
58
76
/// Indicates whether a `char` is whitespace
@@ -61,10 +79,11 @@ pub fn is_uppercase(c: char) -> bool { derived_property::Uppercase(c) }
61
79
///
62
80
#[ inline]
63
81
pub fn is_whitespace ( c : char ) -> bool {
64
- // As an optimization ASCII whitespace characters are checked separately
65
- c == ' '
66
- || ( '\x09' <= c && c <= '\x0d' )
67
- || property:: White_Space ( c)
82
+ match c {
83
+ ' ' | '\x09' .. '\x0d' => true ,
84
+ c if c > '\x7f' => property:: White_Space ( c) ,
85
+ _ => false
86
+ }
68
87
}
69
88
70
89
///
@@ -75,8 +94,8 @@ pub fn is_whitespace(c: char) -> bool {
75
94
///
76
95
#[ inline]
77
96
pub fn is_alphanumeric ( c : char ) -> bool {
78
- derived_property :: Alphabetic ( c)
79
- || general_category :: N ( c)
97
+ is_alphabetic ( c)
98
+ || is_digit ( c)
80
99
}
81
100
82
101
///
@@ -91,7 +110,11 @@ pub fn is_control(c: char) -> bool { general_category::Cc(c) }
91
110
/// Indicates whether the `char` is numeric (Nd, Nl, or No)
92
111
#[ inline]
93
112
pub fn is_digit ( c : char ) -> bool {
94
- general_category:: N ( c)
113
+ match c {
114
+ '0' .. '9' => true ,
115
+ c if c > '\x7f' => general_category:: N ( c) ,
116
+ _ => false
117
+ }
95
118
}
96
119
97
120
/// Convert a char to its uppercase equivalent
0 commit comments