int u_memcasecmp(const UChar* a, const UChar* b, int length, unsigned options) { for (int i = 0; i < length; ++i) { UChar c1 = u_foldCase(a[i], options); UChar c2 = u_foldCase(b[i], options); if (c1 != c2) return c1 - c2; } return 0; }
int ICUTransService::compareNIString(const XMLCh* const comp1 , const XMLCh* const comp2 , const unsigned int maxChars) { if (maxChars > 0) { // Note that this function has somewhat broken semantics, as it's // possible for two strings of different lengths to compare as equal // in a case-insensitive manner, since one character could be // represented as a surrogate pair. size_t i = 0; size_t j = 0; for(;;) { UChar32 ch1; UChar32 ch2; U16_NEXT_UNSAFE(comp1, i, ch1); U16_NEXT_UNSAFE(comp2, j, ch2); const UChar32 folded1 = u_foldCase(ch1, U_FOLD_CASE_DEFAULT); const UChar32 folded2 = u_foldCase(ch2, U_FOLD_CASE_DEFAULT); if (folded1 != folded2) { return folded1 - folded2; } else if (i == maxChars) { // If we're at the end of both strings, return 0. // Otherwise, we've run out of characters in the // left string, so return -1. return j == maxChars ? 0 : -1; } else if (j == maxChars) { // We've run out of characters in the right string, // but not the left, so return 1. return 1; } } } return 0; }
std::string foldcase(const std::string& str) { return transform(str, [](uint32_t cp) { return u_foldCase(static_cast<UChar32>(cp), U_FOLD_CASE_DEFAULT); }); }
Variant HHVM_STATIC_METHOD(IntlChar, foldCase, const Variant& arg, int64_t options) { GETCP(arg, cp); auto ret = u_foldCase(cp, options); if (arg.isString()) { char buffer[5]; int buffer_len = 0; U8_APPEND_UNSAFE(buffer, buffer_len, ret); return String(buffer, buffer_len, CopyString); } else { return ret; } }
// --------------------------------------------------------------------------- // ICUTransService: The virtual transcoding service API // --------------------------------------------------------------------------- int ICUTransService::compareIString(const XMLCh* const comp1 , const XMLCh* const comp2) { size_t i = 0; size_t j = 0; for(;;) { UChar32 ch1; UChar32 ch2; U16_NEXT_UNSAFE(comp1, i, ch1); U16_NEXT_UNSAFE(comp2, j, ch2); const UChar32 folded1 = u_foldCase(ch1, U_FOLD_CASE_DEFAULT); const UChar32 folded2 = u_foldCase(ch2, U_FOLD_CASE_DEFAULT); if (folded1 != folded2) { return folded1 - folded2; } else if (ch1 == 0) { // If ch1 is 0, the ch2 must also be // 0. Otherwise, the previous if // would have failed. break; } } return 0; }
/* ** Prepare to begin tokenizing a particular string. The input ** string to be tokenized is pInput[0..nBytes-1]. A cursor ** used to incrementally tokenize this string is returned in ** *ppCursor. */ static int icuOpen( sqlite3_tokenizer *pTokenizer, /* The tokenizer */ const char *zInput, /* Input string */ int nInput, /* Length of zInput in bytes */ sqlite3_tokenizer_cursor **ppCursor /* OUT: Tokenization cursor */ ){ IcuTokenizer *p = (IcuTokenizer *)pTokenizer; IcuCursor *pCsr; const int32_t opt = U_FOLD_CASE_DEFAULT; UErrorCode status = U_ZERO_ERROR; int nChar; UChar32 c; int iInput = 0; int iOut = 0; *ppCursor = 0; if( nInput<0 ){ nInput = strlen(zInput); } nChar = nInput+1; pCsr = (IcuCursor *)sqlite3_malloc( sizeof(IcuCursor) + /* IcuCursor */ nChar * sizeof(UChar) + /* IcuCursor.aChar[] */ (nChar+1) * sizeof(int) /* IcuCursor.aOffset[] */ ); if( !pCsr ){ return SQLITE_NOMEM; } memset(pCsr, 0, sizeof(IcuCursor)); pCsr->aChar = (UChar *)&pCsr[1]; pCsr->aOffset = (int *)&pCsr->aChar[nChar]; pCsr->aOffset[iOut] = iInput; U8_NEXT(zInput, iInput, nInput, c); while( c>0 ){ int isError = 0; c = u_foldCase(c, opt); U16_APPEND(pCsr->aChar, iOut, nChar, c, isError); if( isError ){ sqlite3_free(pCsr); return SQLITE_ERROR; } pCsr->aOffset[iOut] = iInput; if( iInput<nInput ){ U8_NEXT(zInput, iInput, nInput, c); }else{ c = 0; } } pCsr->pIter = ubrk_open(UBRK_WORD, p->zLocale, pCsr->aChar, iOut, &status); if( !U_SUCCESS(status) ){ sqlite3_free(pCsr); return SQLITE_ERROR; } pCsr->nChar = iOut; ubrk_first(pCsr->pIter); *ppCursor = (sqlite3_tokenizer_cursor *)pCsr; return SQLITE_OK; }
/* ** Compare two UTF-8 strings for equality where the first string is ** a "LIKE" expression. Return true (1) if they are the same and ** false (0) if they are different. */ static int icuLikeCompare( const uint8_t *zPattern, /* LIKE pattern */ const uint8_t *zString, /* The UTF-8 string to compare against */ const UChar32 uEsc /* The escape character */ ){ static const int MATCH_ONE = (UChar32)'_'; static const int MATCH_ALL = (UChar32)'%'; int iPattern = 0; /* Current byte index in zPattern */ int iString = 0; /* Current byte index in zString */ int prevEscape = 0; /* True if the previous character was uEsc */ while( zPattern[iPattern]!=0 ){ /* Read (and consume) the next character from the input pattern. */ UChar32 uPattern; U8_NEXT_UNSAFE(zPattern, iPattern, uPattern); assert(uPattern!=0); /* There are now 4 possibilities: ** ** 1. uPattern is an unescaped match-all character "%", ** 2. uPattern is an unescaped match-one character "_", ** 3. uPattern is an unescaped escape character, or ** 4. uPattern is to be handled as an ordinary character */ if( !prevEscape && uPattern==MATCH_ALL ){ /* Case 1. */ uint8_t c; /* Skip any MATCH_ALL or MATCH_ONE characters that follow a ** MATCH_ALL. For each MATCH_ONE, skip one character in the ** test string. */ while( (c=zPattern[iPattern]) == MATCH_ALL || c == MATCH_ONE ){ if( c==MATCH_ONE ){ if( zString[iString]==0 ) return 0; U8_FWD_1_UNSAFE(zString, iString); } iPattern++; } if( zPattern[iPattern]==0 ) return 1; while( zString[iString] ){ if( icuLikeCompare(&zPattern[iPattern], &zString[iString], uEsc) ){ return 1; } U8_FWD_1_UNSAFE(zString, iString); } return 0; }else if( !prevEscape && uPattern==MATCH_ONE ){ /* Case 2. */ if( zString[iString]==0 ) return 0; U8_FWD_1_UNSAFE(zString, iString); }else if( !prevEscape && uPattern==uEsc){ /* Case 3. */ prevEscape = 1; }else{ /* Case 4. */ UChar32 uString; U8_NEXT_UNSAFE(zString, iString, uString); uString = u_foldCase(uString, U_FOLD_CASE_DEFAULT); uPattern = u_foldCase(uPattern, U_FOLD_CASE_DEFAULT); if( uString!=uPattern ){ return 0; } prevEscape = 0; } } return zString[iString]==0; }
static void TestCaseFolding(void) { /* * CaseFolding.txt says about i and its cousins: * 0049; C; 0069; # LATIN CAPITAL LETTER I * 0049; T; 0131; # LATIN CAPITAL LETTER I * * 0130; F; 0069 0307; # LATIN CAPITAL LETTER I WITH DOT ABOVE * 0130; T; 0069; # LATIN CAPITAL LETTER I WITH DOT ABOVE * That's all. * See CaseFolding.txt and the Unicode Standard for how to apply the case foldings. */ static const UChar32 simple[]={ /* input, default, exclude special i */ 0x61, 0x61, 0x61, 0x49, 0x69, 0x131, 0x130, 0x130, 0x69, 0x131, 0x131, 0x131, 0xdf, 0xdf, 0xdf, 0xfb03, 0xfb03, 0xfb03, 0x1040e,0x10436,0x10436, 0x5ffff,0x5ffff,0x5ffff }; static const UChar mixed[]= { 0x61, 0x42, 0x130, 0x49, 0x131, 0x3d0, 0xdf, 0xfb03, 0xd93f, 0xdfff }, foldedDefault[]= { 0x61, 0x62, 0x69, 0x307, 0x69, 0x131, 0x3b2, 0x73, 0x73, 0x66, 0x66, 0x69, 0xd93f, 0xdfff }, foldedExcludeSpecialI[]={ 0x61, 0x62, 0x69, 0x131, 0x131, 0x3b2, 0x73, 0x73, 0x66, 0x66, 0x69, 0xd93f, 0xdfff }; UVersionInfo unicodeVersion={ 0, 0, 17, 89 }, unicode_3_1={ 3, 1, 0, 0 }; const UChar32 *p; int32_t i; UChar buffer[32]; int32_t length; UErrorCode errorCode; UBool isUnicode_3_1; /* if unicodeVersion()>=3.1 then test exclude-special-i cases as well */ u_getUnicodeVersion(unicodeVersion); isUnicode_3_1= uprv_memcmp(unicodeVersion, unicode_3_1, 4)>=0; /* test simple case folding */ p=simple; for(i=0; i<sizeof(simple)/12; p+=3, ++i) { if(u_foldCase(p[0], U_FOLD_CASE_DEFAULT)!=p[1]) { log_err("error: u_foldCase(0x%04lx, default)=0x%04lx instead of 0x%04lx\n", p[0], u_foldCase(p[0], U_FOLD_CASE_DEFAULT), p[1]); return; } if(isUnicode_3_1 && u_foldCase(p[0], U_FOLD_CASE_EXCLUDE_SPECIAL_I)!=p[2]) { log_err("error: u_foldCase(0x%04lx, exclude special i)=0x%04lx instead of 0x%04lx\n", p[0], u_foldCase(p[0], U_FOLD_CASE_EXCLUDE_SPECIAL_I), p[2]); return; } } /* test full string case folding with default option and separate buffers */ buffer[0]=0xabcd; errorCode=U_ZERO_ERROR; length=u_strFoldCase(buffer, sizeof(buffer)/U_SIZEOF_UCHAR, mixed, sizeof(mixed)/U_SIZEOF_UCHAR, U_FOLD_CASE_DEFAULT, &errorCode); if( U_FAILURE(errorCode) || length!=(sizeof(foldedDefault)/U_SIZEOF_UCHAR) || uprv_memcmp(foldedDefault, buffer, length*U_SIZEOF_UCHAR)!=0 || buffer[length]!=0 ) { log_err("error in u_strFoldCase(default)=%ld error=%s string matches: %s\n", length, u_errorName(errorCode), uprv_memcmp(foldedDefault, buffer, length*U_SIZEOF_UCHAR)==0 && buffer[length]==0 ? "yes" : "no"); } /* exclude special i */ if(isUnicode_3_1) { buffer[0]=0xabcd; errorCode=U_ZERO_ERROR; length=u_strFoldCase(buffer, sizeof(buffer)/U_SIZEOF_UCHAR, mixed, sizeof(mixed)/U_SIZEOF_UCHAR, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode); if( U_FAILURE(errorCode) || length!=(sizeof(foldedExcludeSpecialI)/U_SIZEOF_UCHAR) || uprv_memcmp(foldedExcludeSpecialI, buffer, length*U_SIZEOF_UCHAR)!=0 || buffer[length]!=0 ) { log_err("error in u_strFoldCase(exclude special i)=%ld error=%s string matches: %s\n", length, u_errorName(errorCode), uprv_memcmp(foldedExcludeSpecialI, buffer, length*U_SIZEOF_UCHAR)==0 && buffer[length]==0 ? "yes" : "no"); } } /* test full string case folding with default option and in the same buffer */ uprv_memcpy(buffer, mixed, sizeof(mixed)); buffer[sizeof(mixed)/U_SIZEOF_UCHAR]=0; errorCode=U_ZERO_ERROR; length=u_strFoldCase(buffer, sizeof(buffer)/U_SIZEOF_UCHAR, buffer, -1, /* implicit srcLength */ U_FOLD_CASE_DEFAULT, &errorCode); if( U_FAILURE(errorCode) || length!=(sizeof(foldedDefault)/U_SIZEOF_UCHAR) || uprv_memcmp(foldedDefault, buffer, length*U_SIZEOF_UCHAR)!=0 || buffer[length]!=0 ) { log_err("error in u_strFoldCase(default same buffer)=%ld error=%s string matches: %s\n", length, u_errorName(errorCode), uprv_memcmp(foldedDefault, buffer, length*U_SIZEOF_UCHAR)==0 && buffer[length]==0 ? "yes" : "no"); } /* test full string case folding, exclude special i, in the same buffer */ if(isUnicode_3_1) { uprv_memcpy(buffer, mixed, sizeof(mixed)); errorCode=U_ZERO_ERROR; length=u_strFoldCase(buffer, sizeof(buffer)/U_SIZEOF_UCHAR, buffer, sizeof(mixed)/U_SIZEOF_UCHAR, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode); if( U_FAILURE(errorCode) || length!=(sizeof(foldedExcludeSpecialI)/U_SIZEOF_UCHAR) || uprv_memcmp(foldedExcludeSpecialI, buffer, length*U_SIZEOF_UCHAR)!=0 || buffer[length]!=0 ) { log_err("error in u_strFoldCase(exclude special i same buffer)=%ld error=%s string matches: %s\n", length, u_errorName(errorCode), uprv_memcmp(foldedExcludeSpecialI, buffer, length*U_SIZEOF_UCHAR)==0 && buffer[length]==0 ? "yes" : "no"); } } /* test preflighting */ buffer[0]=buffer[2]=0xabcd; errorCode=U_ZERO_ERROR; length=u_strFoldCase(buffer, 2, /* set destCapacity=2 */ mixed, sizeof(mixed)/U_SIZEOF_UCHAR, U_FOLD_CASE_DEFAULT, &errorCode); if( errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=(sizeof(foldedDefault)/U_SIZEOF_UCHAR) || uprv_memcmp(foldedDefault, buffer, 2*U_SIZEOF_UCHAR)!=0 || buffer[2]!=0xabcd ) { log_err("error in u_strFoldCase(default preflighting)=%ld error=%s string matches: %s\n", length, u_errorName(errorCode), uprv_memcmp(foldedDefault, buffer, 2*U_SIZEOF_UCHAR)==0 && buffer[2]==0xabcd ? "yes" : "no"); } errorCode=U_ZERO_ERROR; length=u_strFoldCase(NULL, 0, mixed, sizeof(mixed)/U_SIZEOF_UCHAR, U_FOLD_CASE_DEFAULT, &errorCode); if( errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=(sizeof(foldedDefault)/U_SIZEOF_UCHAR) ) { log_err("error in u_strFoldCase(default pure preflighting)=%ld error=%s\n", length, u_errorName(errorCode)); } /* test error handling */ errorCode=U_ZERO_ERROR; length=u_strFoldCase(NULL, sizeof(buffer)/U_SIZEOF_UCHAR, mixed, sizeof(mixed)/U_SIZEOF_UCHAR, U_FOLD_CASE_DEFAULT, &errorCode); if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) { log_err("error in u_strFoldCase(default dest=NULL)=%ld error=%s\n", length, u_errorName(errorCode)); } buffer[0]=0xabcd; errorCode=U_ZERO_ERROR; length=u_strFoldCase(buffer, -1, mixed, sizeof(mixed)/U_SIZEOF_UCHAR, U_FOLD_CASE_DEFAULT, &errorCode); if( errorCode!=U_ILLEGAL_ARGUMENT_ERROR || buffer[0]!=0xabcd ) { log_err("error in u_strFoldCase(default destCapacity=-1)=%ld error=%s buffer[0]==0x%lx\n", length, u_errorName(errorCode), buffer[0]); } buffer[0]=0xabcd; errorCode=U_ZERO_ERROR; length=u_strFoldCase(buffer, sizeof(buffer)/U_SIZEOF_UCHAR, NULL, sizeof(mixed)/U_SIZEOF_UCHAR, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode); if( errorCode!=U_ILLEGAL_ARGUMENT_ERROR || buffer[0]!=0xabcd ) { log_err("error in u_strFoldCase(exclude special i src=NULL)=%ld error=%s buffer[0]==0x%lx\n", length, u_errorName(errorCode), buffer[0]); } buffer[0]=0xabcd; errorCode=U_ZERO_ERROR; length=u_strFoldCase(buffer, sizeof(buffer)/U_SIZEOF_UCHAR, mixed, -2, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode); if( errorCode!=U_ILLEGAL_ARGUMENT_ERROR || buffer[0]!=0xabcd ) { log_err("error in u_strFoldCase(exclude special i srcLength=-2)=%ld error=%s buffer[0]==0x%lx\n", length, u_errorName(errorCode), buffer[0]); } }
/* * imp: common/ucase.c * hdr: common/unicode/uchar.h * @stable ICU 2.0 */ U_CAPI UChar32 U_EXPORT2 u_foldCase_4_0(UChar32 c, uint32_t options) { return u_foldCase(c, options); }
/* ** Compare two UTF-8 strings for equality where the first string is ** a "LIKE" expression. Return true (1) if they are the same and ** false (0) if they are different. */ static int icuLikeCompare( const uint8_t *zPattern, /* LIKE pattern */ const uint8_t *zString, /* The UTF-8 string to compare against */ const UChar32 uEsc /* The escape character */ ){ static const int MATCH_ONE = (UChar32)'_'; static const int MATCH_ALL = (UChar32)'%'; int prevEscape = 0; /* True if the previous character was uEsc */ while( 1 ){ /* Read (and consume) the next character from the input pattern. */ UChar32 uPattern; SQLITE_ICU_READ_UTF8(zPattern, uPattern); if( uPattern==0 ) break; /* There are now 4 possibilities: ** ** 1. uPattern is an unescaped match-all character "%", ** 2. uPattern is an unescaped match-one character "_", ** 3. uPattern is an unescaped escape character, or ** 4. uPattern is to be handled as an ordinary character */ if( !prevEscape && uPattern==MATCH_ALL ){ /* Case 1. */ uint8_t c; /* Skip any MATCH_ALL or MATCH_ONE characters that follow a ** MATCH_ALL. For each MATCH_ONE, skip one character in the ** test string. */ while( (c=*zPattern) == MATCH_ALL || c == MATCH_ONE ){ if( c==MATCH_ONE ){ if( *zString==0 ) return 0; SQLITE_ICU_SKIP_UTF8(zString); } zPattern++; } if( *zPattern==0 ) return 1; while( *zString ){ if( icuLikeCompare(zPattern, zString, uEsc) ){ return 1; } SQLITE_ICU_SKIP_UTF8(zString); } return 0; }else if( !prevEscape && uPattern==MATCH_ONE ){ /* Case 2. */ if( *zString==0 ) return 0; SQLITE_ICU_SKIP_UTF8(zString); }else if( !prevEscape && uPattern==uEsc){ /* Case 3. */ prevEscape = 1; }else{ /* Case 4. */ UChar32 uString; SQLITE_ICU_READ_UTF8(zString, uString); uString = u_foldCase(uString, U_FOLD_CASE_DEFAULT); uPattern = u_foldCase(uPattern, U_FOLD_CASE_DEFAULT); if( uString!=uPattern ){ return 0; } prevEscape = 0; } } return *zString==0; }
static void demoCaseMapInC() { /* * input= * "aB<capital sigma>" * "iI<small dotless i><capital dotted I> " * "<sharp s> <small lig. ffi>" * "<small final sigma><small sigma><capital sigma>" */ static const UChar input[]={ 0x61, 0x42, 0x3a3, 0x69, 0x49, 0x131, 0x130, 0x20, 0xdf, 0x20, 0xfb03, 0x3c2, 0x3c3, 0x3a3, 0 }; UChar buffer[32]; UErrorCode errorCode; UChar32 c; int32_t i, j, length; UBool isError; printf("\n* demoCaseMapInC() ----------------- ***\n\n"); /* * First, use simple case mapping functions which provide * 1:1 code point mappings without context/locale ID. * * Note that some mappings will not be "right" because some "real" * case mappings require context, depend on the locale ID, * and/or result in a change in the number of code points. */ printUString("input string: ", input, -1); /* uppercase */ isError=FALSE; for(i=j=0; j<UPRV_LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) { U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */ if(c==0) { break; /* stop at terminating NUL, no need to terminate buffer */ } c=u_toupper(c); U16_APPEND(buffer, j, UPRV_LENGTHOF(buffer), c, isError); } printUString("simple-uppercased: ", buffer, j); /* lowercase */ isError=FALSE; for(i=j=0; j<UPRV_LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) { U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */ if(c==0) { break; /* stop at terminating NUL, no need to terminate buffer */ } c=u_tolower(c); U16_APPEND(buffer, j, UPRV_LENGTHOF(buffer), c, isError); } printUString("simple-lowercased: ", buffer, j); /* titlecase */ isError=FALSE; for(i=j=0; j<UPRV_LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) { U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */ if(c==0) { break; /* stop at terminating NUL, no need to terminate buffer */ } c=u_totitle(c); U16_APPEND(buffer, j, UPRV_LENGTHOF(buffer), c, isError); } printUString("simple-titlecased: ", buffer, j); /* case-fold/default */ isError=FALSE; for(i=j=0; j<UPRV_LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) { U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */ if(c==0) { break; /* stop at terminating NUL, no need to terminate buffer */ } c=u_foldCase(c, U_FOLD_CASE_DEFAULT); U16_APPEND(buffer, j, UPRV_LENGTHOF(buffer), c, isError); } printUString("simple-case-folded/default: ", buffer, j); /* case-fold/Turkic */ isError=FALSE; for(i=j=0; j<UPRV_LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) { U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */ if(c==0) { break; /* stop at terminating NUL, no need to terminate buffer */ } c=u_foldCase(c, U_FOLD_CASE_EXCLUDE_SPECIAL_I); U16_APPEND(buffer, j, UPRV_LENGTHOF(buffer), c, isError); } printUString("simple-case-folded/Turkic: ", buffer, j); /* * Second, use full case mapping functions which provide * 1:n code point mappings (n can be 0!) and are sensitive to context and locale ID. * * Note that lower/upper/titlecasing take a locale ID while case-folding * has bit flag options instead, by design of the Unicode SpecialCasing.txt UCD file. * * Also, string titlecasing requires a BreakIterator to find starts of words. * The sample code here passes in a NULL pointer; u_strToTitle() will open and close a default * titlecasing BreakIterator automatically. * For production code where many strings are titlecased it would be more efficient * to open a BreakIterator externally and pass it in. */ printUString("\ninput string: ", input, -1); /* lowercase/English */ errorCode=U_ZERO_ERROR; length=u_strToLower(buffer, UPRV_LENGTHOF(buffer), input, -1, "en", &errorCode); if(U_SUCCESS(errorCode)) { printUString("full-lowercased/en: ", buffer, length); } else { printf("error in u_strToLower(en)=%ld error=%s\n", length, u_errorName(errorCode)); } /* lowercase/Turkish */ errorCode=U_ZERO_ERROR; length=u_strToLower(buffer, UPRV_LENGTHOF(buffer), input, -1, "tr", &errorCode); if(U_SUCCESS(errorCode)) { printUString("full-lowercased/tr: ", buffer, length); } else { printf("error in u_strToLower(tr)=%ld error=%s\n", length, u_errorName(errorCode)); } /* uppercase/English */ errorCode=U_ZERO_ERROR; length=u_strToUpper(buffer, UPRV_LENGTHOF(buffer), input, -1, "en", &errorCode); if(U_SUCCESS(errorCode)) { printUString("full-uppercased/en: ", buffer, length); } else { printf("error in u_strToUpper(en)=%ld error=%s\n", length, u_errorName(errorCode)); } /* uppercase/Turkish */ errorCode=U_ZERO_ERROR; length=u_strToUpper(buffer, UPRV_LENGTHOF(buffer), input, -1, "tr", &errorCode); if(U_SUCCESS(errorCode)) { printUString("full-uppercased/tr: ", buffer, length); } else { printf("error in u_strToUpper(tr)=%ld error=%s\n", length, u_errorName(errorCode)); } /* titlecase/English */ errorCode=U_ZERO_ERROR; length=u_strToTitle(buffer, UPRV_LENGTHOF(buffer), input, -1, NULL, "en", &errorCode); if(U_SUCCESS(errorCode)) { printUString("full-titlecased/en: ", buffer, length); } else { printf("error in u_strToTitle(en)=%ld error=%s\n", length, u_errorName(errorCode)); } /* titlecase/Turkish */ errorCode=U_ZERO_ERROR; length=u_strToTitle(buffer, UPRV_LENGTHOF(buffer), input, -1, NULL, "tr", &errorCode); if(U_SUCCESS(errorCode)) { printUString("full-titlecased/tr: ", buffer, length); } else { printf("error in u_strToTitle(tr)=%ld error=%s\n", length, u_errorName(errorCode)); } /* case-fold/default */ errorCode=U_ZERO_ERROR; length=u_strFoldCase(buffer, UPRV_LENGTHOF(buffer), input, -1, U_FOLD_CASE_DEFAULT, &errorCode); if(U_SUCCESS(errorCode)) { printUString("full-case-folded/default: ", buffer, length); } else { printf("error in u_strFoldCase(default)=%ld error=%s\n", length, u_errorName(errorCode)); } /* case-fold/Turkic */ errorCode=U_ZERO_ERROR; length=u_strFoldCase(buffer, UPRV_LENGTHOF(buffer), input, -1, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode); if(U_SUCCESS(errorCode)) { printUString("full-case-folded/Turkic: ", buffer, length); } else { printf("error in u_strFoldCase(Turkic)=%ld error=%s\n", length, u_errorName(errorCode)); } }