nlib
nn::nlib::unicode::ToUtf8Obj Class Referencefinal

Class to use to pass a UTF-8, UTF-16, or UTF-32 string as UTF-8. More...

#include "nn/nlib/unicode/Convert.h"

Public Member Functions

 ToUtf8Obj (const wchar_t *wstr) noexcept
 Converts a wide character string to a UTF-8 string. More...
 
 ToUtf8Obj (const nlib_utf16_t *utf16str) noexcept
 Converts a UTF-16 string to a UTF-8 string. More...
 
 ToUtf8Obj (const nlib_utf32_t *utf32str) noexcept
 Converts a UTF-32 string to a UTF-8 string. More...
 
 ToUtf8Obj (const char *str) noexcept
 Sets the UTF-8 string. More...
 
const char * c_str () noexcept
 Explicitly returns a C string. More...
 
bool IsOk () const noexcept
 : Checks whether the object is valid. More...
 

Detailed Description

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.

Definition at line 12 of file Convert.h.

Constructor & Destructor Documentation

nn::nlib::unicode::ToUtf8Obj::ToUtf8Obj ( const wchar_t *  wstr)
explicitnoexcept

Converts a wide character string to a UTF-8 string.

Parameters
[in]wstrWide 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.
nn::nlib::unicode::ToUtf8Obj::ToUtf8Obj ( const nlib_utf16_t utf16str)
explicitnoexcept

Converts a UTF-16 string to a UTF-8 string.

Parameters
[in]utf16strUTF-16 string to pass as a UTF-8 string.
nn::nlib::unicode::ToUtf8Obj::ToUtf8Obj ( const nlib_utf32_t utf32str)
explicitnoexcept

Converts a UTF-32 string to a UTF-8 string.

Parameters
[in]utf32strUTF-32 string to pass as a UTF-8 string.
nn::nlib::unicode::ToUtf8Obj::ToUtf8Obj ( const char *  str)
inlineexplicitnoexcept

Sets the UTF-8 string.

Parameters
[in]strUTF-8 string.
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.

Member Function Documentation

nn::nlib::unicode::ToUtf8Obj::c_str ( )
inlinenoexcept

Explicitly returns a C string.

Returns
C string converted to UTF-8.

Definition at line 26 of file Convert.h.

nn::nlib::unicode::ToUtf8Obj::IsOk ( ) const
inlinenoexcept

: Checks whether the object is valid.

Returns
Returns true if valid.

Definition at line 27 of file Convert.h.


The documentation for this class was generated from the following files: