mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-09 15:27:38 +00:00
ICU-12333 full case mapping set output string to nullptr if length==0, and do not convert the empty string to UTF-8
X-SVN-Rev: 40108
This commit is contained in:
parent
379d2f3a7a
commit
bff565de53
2 changed files with 17 additions and 11 deletions
|
@ -961,6 +961,7 @@ ucase_toFullLower(UChar32 c,
|
|||
0307; ; 0307; 0307; tr After_I; # COMBINING DOT ABOVE
|
||||
0307; ; 0307; 0307; az After_I; # COMBINING DOT ABOVE
|
||||
*/
|
||||
*pString=nullptr;
|
||||
return 0; /* remove the dot (continue without output) */
|
||||
} else if(loc==UCASE_LOC_TURKISH && c==0x49 && !isFollowedByDotAbove(iter, context)) {
|
||||
/*
|
||||
|
@ -1059,6 +1060,7 @@ toUpperOrTitle(UChar32 c,
|
|||
|
||||
0307; 0307; ; ; lt After_Soft_Dotted; # COMBINING DOT ABOVE
|
||||
*/
|
||||
*pString=nullptr;
|
||||
return 0; /* remove the dot (continue without output) */
|
||||
} else {
|
||||
/* no known conditional special case mapping, use a normal mapping */
|
||||
|
|
|
@ -177,18 +177,22 @@ appendResult(uint8_t *dest, int32_t destIndex, int32_t destCapacity,
|
|||
} else {
|
||||
if(result<=UCASE_MAX_STRING_LENGTH) {
|
||||
// string: "result" is the UTF-16 length
|
||||
errorCode=U_ZERO_ERROR;
|
||||
if(destIndex<destCapacity) {
|
||||
u_strToUTF8((char *)(dest+destIndex), destCapacity-destIndex, &length,
|
||||
s, result, &errorCode);
|
||||
if(result==0) {
|
||||
length=0;
|
||||
} else {
|
||||
u_strToUTF8(NULL, 0, &length, s, result, &errorCode);
|
||||
}
|
||||
if(U_FAILURE(errorCode) && errorCode != U_BUFFER_OVERFLOW_ERROR) {
|
||||
return -1;
|
||||
}
|
||||
if(length>(INT32_MAX-destIndex)) {
|
||||
return -1; // integer overflow
|
||||
errorCode=U_ZERO_ERROR;
|
||||
if(destIndex<destCapacity) {
|
||||
u_strToUTF8((char *)(dest+destIndex), destCapacity-destIndex, &length,
|
||||
s, result, &errorCode);
|
||||
} else {
|
||||
u_strToUTF8(NULL, 0, &length, s, result, &errorCode);
|
||||
}
|
||||
if(U_FAILURE(errorCode) && errorCode != U_BUFFER_OVERFLOW_ERROR) {
|
||||
return -1;
|
||||
}
|
||||
if(length>(INT32_MAX-destIndex)) {
|
||||
return -1; // integer overflow
|
||||
}
|
||||
}
|
||||
if(edits!=NULL) {
|
||||
edits->addReplace(cpLength, length);
|
||||
|
|
Loading…
Add table
Reference in a new issue