This library is intended to perform conversions between UTF-8, UTF-16 and UTF-32 text:
namespace utf {
std::u8string to_utf8(...); // convert to UTF-8
std::u16string to_utf16(...); // convert to UTF-16
std::u32string to_utf32(...); // convert to UTF-32
std::string to_string(...); // also convert to UTF-8, but the return type is std::string
}No other function, such as text processing, character classification, normalization, BOM, etc is performed.
The use case is whenever you need to perform conversion to massage data passed around between libraries, and you don't have (or don't want to use) existing general-purpose text encoding conversions:
-
iconv()isn't always available in embedded systems; when statically linked, it adds all conversion tables to the executable, even the non-Unicode ones. -
ICUwill solve all your Unicode needs, but it's massive.
Utf-cpp is licensed under multiple licenses, you can choose which one to abide: