Commit c7712e2e authored by Max Kellermann's avatar Max Kellermann

lib/icu/Collate: fall back to strxfrm()

parent 61fa7706
......@@ -180,8 +180,22 @@ IcuCaseFold(const char *src)
std::string result(tmp);
g_free(tmp);
#else
std::string result(src);
std::transform(result.begin(), result.end(), result.begin(), tolower);
size_t size = strlen(src) + 1;
auto buffer = new char[size];
size_t nbytes = strxfrm(buffer, src, size);
if (nbytes >= size) {
/* buffer too small - reallocate and try again */
delete[] buffer;
size = nbytes + 1;
buffer = new char[size];
nbytes = strxfrm(buffer, src, size);
}
assert(nbytes < size);
assert(buffer[nbytes] == 0);
std::string result(buffer, nbytes);
delete[] buffer;
#endif
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment