lib/icu/Collate: use class AllocatedArray
This commit is contained in:
@@ -144,22 +144,18 @@ IcuCaseFold(const char *src)
|
|||||||
if (u.IsNull())
|
if (u.IsNull())
|
||||||
return AllocatedString<>::Duplicate(src);
|
return AllocatedString<>::Duplicate(src);
|
||||||
|
|
||||||
size_t folded_capacity = u.size() * 2u;
|
AllocatedArray<UChar> folded(u.size() * 2u);
|
||||||
UChar *folded = new UChar[folded_capacity];
|
|
||||||
|
|
||||||
UErrorCode error_code = U_ZERO_ERROR;
|
UErrorCode error_code = U_ZERO_ERROR;
|
||||||
size_t folded_length = u_strFoldCase(folded, folded_capacity,
|
size_t folded_length = u_strFoldCase(folded.begin(), folded.size(),
|
||||||
u.begin(), u.size(),
|
u.begin(), u.size(),
|
||||||
U_FOLD_CASE_DEFAULT,
|
U_FOLD_CASE_DEFAULT,
|
||||||
&error_code);
|
&error_code);
|
||||||
if (folded_length == 0 || error_code != U_ZERO_ERROR) {
|
if (folded_length == 0 || error_code != U_ZERO_ERROR)
|
||||||
delete[] folded;
|
|
||||||
return AllocatedString<>::Duplicate(src);
|
return AllocatedString<>::Duplicate(src);
|
||||||
}
|
|
||||||
|
|
||||||
auto result = UCharToUTF8({folded, folded_length});
|
folded.SetSize(folded_length);
|
||||||
delete[] folded;
|
return UCharToUTF8({folded.begin(), folded.size()});
|
||||||
return result;
|
|
||||||
|
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
const auto u = MultiByteToWideChar(CP_UTF8, src);
|
const auto u = MultiByteToWideChar(CP_UTF8, src);
|
||||||
|
Reference in New Issue
Block a user