8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- #[ forbid( deprecated_mode) ] ;
12
11
#[ allow( missing_doc) ] ;
13
12
14
13
pub mod icu {
@@ -159,7 +158,10 @@ pub mod icu {
159
158
pub static UCHAR_INVALID_CODE : UProperty = -1 ;
160
159
161
160
pub mod libicu {
162
- #[ link_name = "icuuc" ]
161
+ use unicode:: icu:: * ;
162
+
163
+ // #[link_name = "icuuc"]
164
+ #[ link_args = "-licuuc" ]
163
165
#[ abi = "cdecl" ]
164
166
extern {
165
167
pub fn u_hasBinaryProperty ( c : UChar32 , which : UProperty ) -> UBool ;
@@ -174,13 +176,17 @@ pub mod icu {
174
176
}
175
177
176
178
pub fn is_XID_start ( c : char ) -> bool {
177
- return icu:: libicu:: u_hasBinaryProperty ( c, icu:: UCHAR_XID_START )
178
- == icu:: TRUE ;
179
+ unsafe {
180
+ return icu:: libicu:: u_hasBinaryProperty ( c, icu:: UCHAR_XID_START )
181
+ == icu:: TRUE ;
182
+ }
179
183
}
180
184
181
185
pub fn is_XID_continue ( c : char ) -> bool {
182
- return icu:: libicu:: u_hasBinaryProperty ( c, icu:: UCHAR_XID_START )
183
- == icu:: TRUE ;
186
+ unsafe {
187
+ return icu:: libicu:: u_hasBinaryProperty ( c, icu:: UCHAR_XID_START )
188
+ == icu:: TRUE ;
189
+ }
184
190
}
185
191
186
192
/*
@@ -189,7 +195,9 @@ Function: is_digit
189
195
Returns true if a character is a digit.
190
196
*/
191
197
pub fn is_digit ( c : char ) -> bool {
192
- return icu:: libicu:: u_isdigit ( c) == icu:: TRUE ;
198
+ unsafe {
199
+ return icu:: libicu:: u_isdigit ( c) == icu:: TRUE ;
200
+ }
193
201
}
194
202
195
203
/*
@@ -198,7 +206,9 @@ Function: is_lower
198
206
Returns true if a character is a lowercase letter.
199
207
*/
200
208
pub fn is_lower ( c : char ) -> bool {
201
- return icu:: libicu:: u_islower ( c) == icu:: TRUE ;
209
+ unsafe {
210
+ return icu:: libicu:: u_islower ( c) == icu:: TRUE ;
211
+ }
202
212
}
203
213
204
214
/*
@@ -207,7 +217,9 @@ Function: is_space
207
217
Returns true if a character is space.
208
218
*/
209
219
pub fn is_space ( c : char ) -> bool {
210
- return icu:: libicu:: u_isspace ( c) == icu:: TRUE ;
220
+ unsafe {
221
+ return icu:: libicu:: u_isspace ( c) == icu:: TRUE ;
222
+ }
211
223
}
212
224
213
225
/*
@@ -216,33 +228,36 @@ Function: is_upper
216
228
Returns true if a character is an uppercase letter.
217
229
*/
218
230
pub fn is_upper ( c : char ) -> bool {
219
- return icu:: libicu:: u_isupper ( c) == icu:: TRUE ;
231
+ unsafe {
232
+ return icu:: libicu:: u_isupper ( c) == icu:: TRUE ;
233
+ }
220
234
}
221
235
222
236
#[ cfg( test) ]
223
237
mod tests {
238
+ use unicode:: * ;
224
239
225
240
#[ test]
226
241
fn test_is_digit ( ) {
227
- assert ! ( ( unicode :: icu :: is_digit( '0' ) ) ) ;
228
- assert ! ( ( !unicode :: icu :: is_digit( 'm' ) ) ) ;
242
+ assert ! ( ( is_digit( '0' ) ) ) ;
243
+ assert ! ( ( !is_digit( 'm' ) ) ) ;
229
244
}
230
245
231
246
#[ test]
232
247
fn test_is_lower ( ) {
233
- assert ! ( ( unicode :: icu :: is_lower( 'm' ) ) ) ;
234
- assert ! ( ( !unicode :: icu :: is_lower( 'M' ) ) ) ;
248
+ assert ! ( ( is_lower( 'm' ) ) ) ;
249
+ assert ! ( ( !is_lower( 'M' ) ) ) ;
235
250
}
236
251
237
252
#[ test]
238
253
fn test_is_space ( ) {
239
- assert ! ( ( unicode :: icu :: is_space( ' ' ) ) ) ;
240
- assert ! ( ( !unicode :: icu :: is_space( 'm' ) ) ) ;
254
+ assert ! ( ( is_space( ' ' ) ) ) ;
255
+ assert ! ( ( !is_space( 'm' ) ) ) ;
241
256
}
242
257
243
258
#[ test]
244
259
fn test_is_upper ( ) {
245
- assert ! ( ( unicode :: icu :: is_upper( 'M' ) ) ) ;
246
- assert ! ( ( !unicode :: icu :: is_upper( 'm' ) ) ) ;
260
+ assert ! ( ( is_upper( 'M' ) ) ) ;
261
+ assert ! ( ( !is_upper( 'm' ) ) ) ;
247
262
}
248
263
}
0 commit comments