I'm searching a technique to convert a string (a JSON) sent by a server containing something like this :
...."Test \u00e9\u00e9\u00e9".....
in something like : "Test ééé"
I found a solution : boost::replace_all(listFolder, "\\u00e9", "é");
and I'm using this boost function with the other letters àùèê etc.... that's painful !
I wonder if there is a function who did this kind of conversion automatically.
Otherwise, I want to tell you something else, the server will treat correctly strings I send to it and containing letters with accents if I use this function :
std::string fromLocale(std::string localeStr)
{
boost::locale::generator g;
g.locale_cache_enabled(true);
std::locale loc = g(boost::locale::util::get_system_locale());
return boost::locale::conv::to_utf<char>(localeStr,loc);
}
unfortunately, the inverse of that code didn't work to treat the strings sent by the server.
std::string toLocale(std::string utf8Str)
{
boost::locale::generator g;
g.locale_cache_enabled(true);
std::locale loc = g(boost::locale::util::get_system_locale());
return boost::locale::conv::from_utf<char>(utf8Str,loc);
}