Basic conversion functions between UTF-8, UTF-16 and UTF-32.
More...
|
std::string | utf8::narrow (const wchar_t *s, size_t nch) |
| Conversion from wide character to UTF-8.
|
|
std::string | utf8::narrow (const std::wstring &ws) |
| Conversion from wide character to UTF-8.
|
|
std::string | utf8::narrow (const char32_t *s, size_t nch) |
| Conversion from UTF32 to UTF8.
|
|
std::string | utf8::narrow (const std::u32string &s) |
| Conversion from UTF32 to UTF8.
|
|
std::string | utf8::narrow (char32_t r) |
| Conversion from UTF32 to UTF8.
|
|
std::wstring | utf8::widen (const char *s, size_t nch) |
| Conversion from UTF-8 to wide character.
|
|
std::wstring | utf8::widen (const std::string &s) |
| Conversion from UTF-8 to wide character.
|
|
std::u32string | utf8::runes (const char *s, size_t nch) |
| Conversion from UTF-8 to UTF-32.
|
|
std::u32string | utf8::runes (const std::string &s) |
| Converts a string of characters from UTF-8 to UTF-32.
|
|
char32_t | utf8::rune (const char *p) |
| Conversion from UTF-8 to UTF-32.
|
|
char32_t | utf8::rune (const std::string::const_iterator &p) |
| Conversion from UTF-8 to UTF-32.
|
|
Basic conversion functions between UTF-8, UTF-16 and UTF-32.
◆ narrow() [1/5]
std::string utf8::narrow |
( |
char32_t |
r | ) |
|
Conversion from UTF32 to UTF8.
- Parameters
-
r | UTF-32 encoded character |
- Returns
- UTF-8 encoded string
If the input string contains invalid UTF-32 characters, they are replaced with utf8::REPLACEMENT_CHARACTER (0xFFFD) or the function throws an exception, depending on error handling mode.
◆ narrow() [2/5]
std::string utf8::narrow |
( |
const char32_t * |
s, |
|
|
size_t |
nch |
|
) |
| |
Conversion from UTF32 to UTF8.
- Parameters
-
s | UTF-32 encoded string |
nch | number of character to convert or 0 if string is null-terminated |
- Returns
- UTF-8 encoded string
If the input string contains invalid UTF-32 characters, they are replaced with utf8::REPLACEMENT_CHARACTER (0xFFFD) or the function throws an exception, depending on error handling mode.
◆ narrow() [3/5]
std::string utf8::narrow |
( |
const std::u32string & |
s | ) |
|
Conversion from UTF32 to UTF8.
- Parameters
-
- Returns
- UTF-8 encoded string
If the input string contains invalid UTF-32 characters, they are replaced with utf8::REPLACEMENT_CHARACTER (0xFFFD) or the function throws an exception, depending on error handling mode.
◆ narrow() [4/5]
std::string utf8::narrow |
( |
const std::wstring & |
ws | ) |
|
Conversion from wide character to UTF-8.
- Parameters
-
- Returns
- UTF-8 character string
◆ narrow() [5/5]
std::string utf8::narrow |
( |
const wchar_t * |
s, |
|
|
size_t |
nch |
|
) |
| |
Conversion from wide character to UTF-8.
- Parameters
-
s | input string |
nch | number of character to convert or 0 if string is null-terminated |
- Returns
- UTF-8 character string
◆ rune() [1/2]
char32_t utf8::rune |
( |
const char * |
p | ) |
|
|
inline |
Conversion from UTF-8 to UTF-32.
- Parameters
-
- Returns
- UTF-32 encoded character or utf8::REPLACEMENT_CHARACTER (0xfffd) if it is an invalid UTF-8 encoding
◆ rune() [2/2]
char32_t utf8::rune |
( |
const std::string::const_iterator & |
p | ) |
|
|
inline |
Conversion from UTF-8 to UTF-32.
- Parameters
-
- Returns
- UTF-32 encoded character or utf8::REPLACEMENT_CHARACTER (0xfffd) if it is an invalid UTF-8 encoding
◆ runes() [1/2]
std::u32string utf8::runes |
( |
const char * |
s, |
|
|
size_t |
nch |
|
) |
| |
Conversion from UTF-8 to UTF-32.
- Parameters
-
s | UTF-8 encoded string |
nch | number of characters to convert or 0 if string is null-terminated |
- Returns
- UTF-32 encoded string
If the input string contains invalid UTF-8 characters, they are replaced with utf8::REPLACEMENT_CHARACTER (0xFFFD) or the function throws an exception, depending on error handling mode.
◆ runes() [2/2]
std::u32string utf8::runes |
( |
const std::string & |
s | ) |
|
Converts a string of characters from UTF-8 to UTF-32.
- Parameters
-
- Returns
- UTF-32 encoded string
If the input string contains invalid UTF-8 characters, they are replaced with utf8::REPLACEMENT_CHARACTER (0xFFFD) or the function throws an exception, depending on error handling mode.
◆ widen() [1/2]
std::wstring utf8::widen |
( |
const char * |
s, |
|
|
size_t |
nch |
|
) |
| |
Conversion from UTF-8 to wide character.
- Parameters
-
s | input string |
nch | number of characters to convert or 0 if string is null-terminated |
- Returns
- wide character string
◆ widen() [2/2]
std::wstring utf8::widen |
( |
const std::string & |
s | ) |
|
Conversion from UTF-8 to wide character.
- Parameters
-
- Returns
- wide character string