Class to use to pass a UTF-8, UTF-16, or UTF-32 string as UTF-8.
More...
#include "nn/nlib/unicode/Convert.h"
Class to use to pass a UTF-8, UTF-16, or UTF-32 string as UTF-8.
- Description
- Because
operator const char*
is defined, you can pass to function arguments as a multibyte character string. If the conversion fails and the object is invalid, an empty string is passed instead of a null pointer. This class exists as a utility for running codes handling UTF-8 string literals in Visual Studio. The class is used by defining a macro as follows: #ifdef _MSC_VER
#define X(str) L##str
#else
#define X(str)
#endif
......
UseTextAsUtf8(X("my utf8 text"));
Definition at line 12 of file Convert.h.
§ ToUtf8Obj() [1/4]
nn::nlib::unicode::ToUtf8Obj::ToUtf8Obj |
( |
const wchar_t * |
wstr | ) |
|
|
explicitnoexcept |
Converts a wide character string to a UTF-8 string.
- Parameters
-
[in] | wstr | Wide character string to pass as a UTF-8 string. |
- Description
- Stores the UTF-8 converted string internally in dynamically allocated memory. The object becomes invalid if the conversion fails.
§ ToUtf8Obj() [2/4]
nn::nlib::unicode::ToUtf8Obj::ToUtf8Obj |
( |
const nlib_utf16_t * |
utf16str | ) |
|
|
explicitnoexcept |
Converts a UTF-16 string to a UTF-8 string.
- Parameters
-
[in] | utf16str | UTF-16 string to pass as a UTF-8 string. |
§ ToUtf8Obj() [3/4]
nn::nlib::unicode::ToUtf8Obj::ToUtf8Obj |
( |
const nlib_utf32_t * |
utf32str | ) |
|
|
explicitnoexcept |
Converts a UTF-32 string to a UTF-8 string.
- Parameters
-
[in] | utf32str | UTF-32 string to pass as a UTF-8 string. |
§ ToUtf8Obj() [4/4]
nn::nlib::unicode::ToUtf8Obj::ToUtf8Obj |
( |
const char * |
str | ) |
|
|
inlineexplicitnoexcept |
Sets the UTF-8 string.
- Parameters
-
- Description
- Stores the passed pointer in the object. Does not dynamically allocate memory or copy the string.
Definition at line 17 of file Convert.h.
§ c_str()
nn::nlib::unicode::ToUtf8Obj::c_str |
( |
| ) |
|
|
inlinenoexcept |
Explicitly returns a C string.
- Returns
- C string converted to UTF-8.
Definition at line 24 of file Convert.h.
The documentation for this class was generated from the following files: