| 3199 | | //#define REF_CASE_PART a1+1 |
| | 3199 | void _lowercaseUcs16( uint16_t* it, uint16_t* end ) |
| | 3200 | { |
| | 3201 | int c; |
| | 3202 | while( it != end ) |
| | 3203 | { |
| | 3204 | c = *it; |
| | 3205 | if( (c >= 'A') && (c <= 'Z') ) |
| | 3206 | *it = c + 32; |
| | 3207 | else if( (c >= 0x00C0) && (c <= 0x00DE) && (c != 0x00D7) ) |
| | 3208 | *it = c + 32; |
| | 3209 | else if( (c >= 0x0391) && (c <= 0x03AB) && (c != 0x03A2) ) |
| | 3210 | *it = c + 32; |
| | 3211 | else if( (c >= 0x0410) && (c <= 0x042F) ) |
| | 3212 | *it = c + 32; |
| | 3213 | else if( (c >= 0x0531) && (c <= 0x0556) ) |
| | 3214 | *it = c + 48; |
| | 3215 | // TODO: Implement full lookup table. |
| | 3216 | ++it; |
| | 3217 | } |
| | 3218 | } |
| | 3219 | |
| | 3220 | void _lowercaseAscii( char* it, char* end ) |
| | 3221 | { |
| | 3222 | int c; |
| | 3223 | while( it != end ) |
| | 3224 | { |
| | 3225 | c = *it; |
| | 3226 | if( (c >= 'A') && (c <= 'Z') ) |
| | 3227 | *it = c + ('a' - 'A'); |
| | 3228 | ++it; |
| | 3229 | } |
| | 3230 | } |
| | 3231 | |
| | 3238 | int len; |
| | 3239 | int part; |
| | 3240 | char* cp; |
| | 3241 | char* end; |
| | 3242 | UString* str; |
| | 3243 | |
| | 3244 | #ifdef LANG_THUNE |
| | 3245 | if( ur_is(tos, UT_INT) ) |
| | 3246 | { |
| | 3247 | UR_S_DROP; |
| | 3248 | part = ur_int(tos); |
| | 3249 | tos = ur_s_prev(tos); |
| | 3250 | } |
| | 3251 | else |
| | 3252 | #endif |
| | 3253 | { |
| | 3254 | part = -1; |
| | 3255 | } |
| | 3256 | |
| | 3257 | str = ur_stringSlice( ut, tos, &cp, &end ); |
| | 3258 | if( str ) |
| | 3259 | { |
| | 3260 | if( cp ) |
| | 3261 | { |
| | 3262 | if( ur_encoding(tos) == UR_ENC_UTF16 ) |
| | 3263 | { |
| | 3264 | uint16_t* cp16 = (uint16_t*) cp; |
| | 3265 | uint16_t* end16 = (uint16_t*) end; |
| | 3266 | if( part > -1 ) |
| | 3267 | { |
| | 3268 | len = end16 - cp16; |
| | 3269 | if( part < len ) |
| | 3270 | end16 = cp16 + part; |
| | 3271 | } |
| | 3272 | _lowercaseUcs16( cp16, end16 ); |
| | 3273 | } |
| | 3274 | else |
| | 3275 | { |
| | 3276 | if( part > -1 ) |
| | 3277 | { |
| | 3278 | len = end - cp; |
| | 3279 | if( part < len ) |
| | 3280 | end = cp + part; |
| | 3281 | } |
| | 3282 | _lowercaseAscii( cp, end ); |
| | 3283 | } |
| | 3284 | } |
| | 3285 | } |
| | 3286 | else |
| | 3287 | { |
| | 3288 | ur_throwErr( UR_ERR_DATATYPE, "lowercase expected string!" ); |
| | 3289 | } |
| | 3290 | } |
| | 3291 | |
| | 3292 | |
| | 3293 | void _uppercaseUcs16( uint16_t* it, uint16_t* end ) |
| | 3294 | { |
| 3207 | | UString* str = ur_bin(tos); |
| 3208 | | char* cp = str->ptr.c + tos->series.it; |
| 3209 | | char* end = str->ptr.c + str->used; |
| 3210 | | |
| 3211 | | UR_CALL_UNUSED_TH |
| 3212 | | #if 0 |
| 3213 | | if( orRefineSet(REF_CASE_PART) ) |
| 3214 | | { |
| 3215 | | char* pend; |
| 3216 | | UCell* a3 = tos + 2; |
| 3217 | | if( ur_ins(a3) < 0 ) |
| 3218 | | { |
| 3219 | | ur_throwErr( 0, "/part less than zero." ); |
| 3220 | | return; |
| 3221 | | } |
| 3222 | | pend = cp + ur_int(a3); |
| 3223 | | if( end > pend ) |
| 3224 | | end = pend; |
| 3225 | | } |
| 3226 | | #endif |
| 3227 | | |
| 3228 | | while( cp != end ) |
| 3229 | | { |
| 3230 | | c = *cp; |
| 3231 | | if( (c >= 'A') && (c <= 'Z') ) |
| 3232 | | *cp = c + ('a' - 'A'); |
| 3233 | | ++cp; |
| | 3296 | while( it != end ) |
| | 3297 | { |
| | 3298 | c = *it; |
| | 3299 | if( (c >= 'a') && (c <= 'z') ) |
| | 3300 | *it = c - 32; |
| | 3301 | else if( (c >= 0x00E0) && (c <= 0x00FE) && (c != 0x00F7) ) |
| | 3302 | *it = c - 32; |
| | 3303 | else if( (c >= 0x03B1) && (c <= 0x03CB) && (c != 0x03C2) ) |
| | 3304 | *it = c - 32; |
| | 3305 | else if( (c >= 0x0430) && (c <= 0x044F) ) |
| | 3306 | *it = c - 32; |
| | 3307 | else if( (c >= 0x0561) && (c <= 0x0586) ) |
| | 3308 | *it = c - 48; |
| | 3309 | // TODO: Implement full lookup table. |
| | 3310 | ++it; |
| | 3311 | } |
| | 3312 | } |
| | 3313 | |
| | 3314 | void _uppercaseAscii( char* it, char* end ) |
| | 3315 | { |
| | 3316 | int c; |
| | 3317 | while( it != end ) |
| | 3318 | { |
| | 3319 | c = *it; |
| | 3320 | if( (c >= 'a') && (c <= 'z') ) |
| | 3321 | *it = c - ('a' - 'A'); |
| | 3322 | ++it; |
| 3264 | | |
| 3265 | | while( cp != end ) |
| 3266 | | { |
| 3267 | | c = *cp; |
| 3268 | | if( (c >= 'a') && (c <= 'z') ) |
| 3269 | | *cp = c - ('a' - 'A'); |
| 3270 | | ++cp; |
| | 3348 | { |
| | 3349 | part = -1; |
| | 3350 | } |
| | 3351 | |
| | 3352 | str = ur_stringSlice( ut, tos, &cp, &end ); |
| | 3353 | if( str ) |
| | 3354 | { |
| | 3355 | if( cp ) |
| | 3356 | { |
| | 3357 | if( ur_encoding(tos) == UR_ENC_UTF16 ) |
| | 3358 | { |
| | 3359 | uint16_t* cp16 = (uint16_t*) cp; |
| | 3360 | uint16_t* end16 = (uint16_t*) end; |
| | 3361 | if( part > -1 ) |
| | 3362 | { |
| | 3363 | len = end16 - cp16; |
| | 3364 | if( part < len ) |
| | 3365 | end16 = cp16 + part; |
| | 3366 | } |
| | 3367 | _uppercaseUcs16( cp16, end16 ); |
| | 3368 | } |
| | 3369 | else |
| | 3370 | { |
| | 3371 | if( part > -1 ) |
| | 3372 | { |
| | 3373 | len = end - cp; |
| | 3374 | if( part < len ) |
| | 3375 | end = cp + part; |
| | 3376 | } |
| | 3377 | _uppercaseAscii( cp, end ); |
| | 3378 | } |
| | 3379 | } |
| | 3380 | } |
| | 3381 | else |
| | 3382 | { |
| | 3383 | ur_throwErr( UR_ERR_DATATYPE, "uppercase expected string!" ); |