Reputation: 113
I need to convert incoming strings in UTF-8 encoding into country-specific code pages - e.g. ISO-8859-2 (ISO Latin-2).
The important things is, I want to be independent from the presence of proper locales on the system. The goal of that conversion is not internationalization, in the sense that my program should have proper output on multilingual users' machines. The conversion has to create data for external devices which need predefined encodings.
So far, I just created a map which defines conversions from Unicode codepoints to ISO-8859-2 equivalents. I use std::wstring_convert<std::codecvt_utf8<wchar_t>>
to convert UTF-8 std::string
into Unicode std::wstring
, and then I make conversions using the defined map. Of course, I suppose there are better ways.
Are there any solutions available in standard C++ libraries, Boost, or others, making it possible to perform such conversions? Is it possible to "link" a locale setting such as charset to the application, so that it can work independently from system locales?
Upvotes: 0
Views: 412
Reputation: 1780
You might like to take a look at International Components for Unicode (ICU), which has character conversion functions.
Upvotes: 1