C++98 String Conversion Convenience Functions

Ice provides two helper functions that allow you to convert between narrow strings and UTF-8 encoded strings using a string converter:

C++
namespace Ice
{
    std::string nativeToUTF8(const std::string&, const StringConverterPtr&);
    std::string UTF8ToNative(const std::string&, const StringConverterPtr&);
}

No conversion is performed when the provided string converter is null.

Ice provides two additional helper functions that allow you to convert between wide strings and narrow strings using the provided string converters:

C++
namespace Ice
{
    std::string wstringToString(const std::wstring&, const StringConverterPtr& = 0, const WstringConverterPtr& = 0);
    std::wstring stringToWstring(const std::string&, const StringConverterPtr& = 0, const WstringConverterPtr& = 0);
}

When the narrow string converter given to wstringToString is null, the encoding of the returned narrow string is UTF-8. When the wide string converter given to wstringToString is null, the encoding of wide string parameter is UTF-16 or UTF-32, depending on the size of wchar_t.

Likewise for stringToWstring, when the wide string converter is null, the encoding of the returned wide string is UTF-16 or UTF-32 depending on the size of wchar_t. When the narrow string converter given to stringToWstring is null, the encoding of narrow string parameter is UTF-8.

See Also