CXStringUTF16

From cxwiki

The CXStringUTF16 class provides a translation mechanism to work with native APIs that require UTF-16 text encodings. It is not intended as an internal-use string container and does not provide additional functionality beyond converting to and from UTF-16.
 

Construction

The following constructors are available, including conversion from a UTF-8 encoded text.

// Construct an empty string.
CXStringUTF16(void);

// Construct a string from an existing UTF-16 text.
CXStringUTF16(const CXStringUTF16& utf16);
CXStringUTF16(const uint16* __nullable utf16);
CXStringUTF16(const uint16* __nullable utf16, size_t elementLength);

// Construct a string by converting an existing UTF-8 text.
CXStringUTF16(const char* __nullable utf8);
CXStringUTF16(const char* __nullable utf8, size_t byteLength);

  

Accessors

Accessors exist for direct access to the UTF-16 text, and for converting to a standard UTF-8 encoded CXString.

// Convert to UTF-8.
operator CXString(void) const;

// Returns an internal pointer to this object's string payload.
// The payload is zero-terminated in the usual UTF-16 manner.
operator const uint16* __nonnull (void) const;

// Returns the length (in uint16 elements, NOT bytes and NOT 
// glyphs) of this object's string payload.
size_t Length(void) const;

// Adds a single unicode codepoint to the end of this string.
void AddUnicodeGlyph(uint32 glyph);

// Adds a UTF-16 encoded text to the end of this string.
void Add(const uint16* __nonnull str);