lib/icu/Util: UCharFromUTF8() throws on error

This commit is contained in:
Max Kellermann
2016-04-21 11:20:41 +02:00
parent 423cd5900e
commit 21f17270a1
4 changed files with 15 additions and 8 deletions

View File

@@ -99,13 +99,16 @@ IcuCollate(const char *a, const char *b)
#else
/* fall back to ucol_strcoll() */
const auto au = UCharFromUTF8(a);
const auto bu = UCharFromUTF8(b);
try {
const auto au = UCharFromUTF8(a);
const auto bu = UCharFromUTF8(b);
return !au.IsNull() && !bu.IsNull()
? (int)ucol_strcoll(collator, au.begin(), au.size(),
bu.begin(), bu.size())
: strcasecmp(a, b);
return ucol_strcoll(collator, au.begin(), au.size(),
bu.begin(), bu.size());
} catch (const std::runtime_error &) {
/* fall back to plain strcasecmp() */
return strcasecmp(a, b);
}
#endif
#elif defined(WIN32)