mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
Add better debugging for text conversion failure
This commit is contained in:
parent
4b20128144
commit
a95ab5a7ce
@ -161,12 +161,24 @@ uint32_t TextOperations::getUnicodeCodepoint(char data, const std::string & enco
|
|||||||
|
|
||||||
std::string TextOperations::toUnicode(const std::string &text, const std::string &encoding)
|
std::string TextOperations::toUnicode(const std::string &text, const std::string &encoding)
|
||||||
{
|
{
|
||||||
return boost::locale::conv::to_utf<char>(text, encoding);
|
try {
|
||||||
|
return boost::locale::conv::to_utf<char>(text, encoding);
|
||||||
|
}
|
||||||
|
catch (const boost::locale::conv::conversion_error &)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Failed to convert text '" + text + "' from encoding " + encoding );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TextOperations::fromUnicode(const std::string &text, const std::string &encoding)
|
std::string TextOperations::fromUnicode(const std::string &text, const std::string &encoding)
|
||||||
{
|
{
|
||||||
return boost::locale::conv::from_utf<char>(text, encoding);
|
try {
|
||||||
|
return boost::locale::conv::from_utf<char>(text, encoding);
|
||||||
|
}
|
||||||
|
catch (const boost::locale::conv::conversion_error &)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Failed to convert text '" + text + "' to encoding " + encoding );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextOperations::trimRightUnicode(std::string & text, const size_t amount)
|
void TextOperations::trimRightUnicode(std::string & text, const size_t amount)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user