OpenEnroth d1a3925
Loading...
Searching...
No Matches
Functions
txt Namespace Reference

Functions

std::string wideToUtf8 (std::wstring_view wstr)
 
std::wstring utf8ToWide (std::string_view str)
 
std::string encodedToUtf8 (std::string_view str, TextEncoding encoding)
 
std::string utf8ToEncoded (std::string_view str, TextEncoding encoding)
 

Function Documentation

◆ encodedToUtf8()

std::string txt::encodedToUtf8 ( std::string_view  str,
TextEncoding  encoding 
)

Convert a string from the given encoding to UTF-8.

Invalid or incomplete byte sequences are replaced the Unicode replacement character (U+FFFD).

Parameters
strString in the source encoding.
encodingSource encoding.
Returns
UTF-8 encoded string.

◆ utf8ToEncoded()

std::string txt::utf8ToEncoded ( std::string_view  str,
TextEncoding  encoding 
)

Convert a UTF-8 string to the given encoding.

Characters that cannot be represented in the target encoding are replaced with ? or with the Unicode replacement character (U+FFFD).

Parameters
strUTF-8 string to convert.
encodingTarget encoding.
Returns
String in the target encoding.

◆ utf8ToWide()

std::wstring txt::utf8ToWide ( std::string_view  str)

Convert a UTF-8 string to a wide string.

On Windows, the output is UTF-16. On other platforms, the output is UTF-32. Invalid sequences are replaced with the Unicode replacement character (U+FFFD).

Parameters
strUTF-8 string to convert.
Returns
Wide string.

◆ wideToUtf8()

std::string txt::wideToUtf8 ( std::wstring_view  wstr)

Convert a wide string to UTF-8.

On Windows, the wide string is assumed to be UTF-16. On other platforms, it's assumed to be UTF-32. Invalid sequences are replaced with the Unicode replacement character (U+FFFD).

Parameters
wstrWide string to convert.
Returns
UTF-8 encoded string.