## wxMBConvUTF8

This class converts between the UTF-8 encoding and Unicode. It has one predefined instance, wxConvUTF8.

Derived from

wxMBConv

Include files

<wx/strconv.h>

See also

wxMBConvUTF7, wxMBConv classes overview

Remarks

UTF-8 is a compatibility encoding used to encode Unicode text into anything that was originally written for 8-bit strings, including (but not limited to) filenames, transfer protocols, and database fields. Notable properties include:

- Variable-length encoding able to encode up to 31 bits per character
- ASCII characters (character values under 128) are encoded as plain ASCII (1 byte per character)
- Null bytes do not occur in the encoding, except when there's an actual Unicode null character
- Preserves sort ordering for plain 8-bit comparison routines like strcmp()
- High bit patterns unambiguates character boundaries, and makes it easy to detect whether a string is encoded with UTF-8 or not

All of these properties make UTF-8 a very favorable solution in any situation where full Unicode character support is desired while remaining compatible with code written with only 8-bit extended-ASCII characters in mind.

Members

wxMBConvUTF8::MB2WC
wxMBConvUTF8::WC2MB

### wxMBConvUTF8::MB2WC

size_t MB2WC(wchar_t* buf, const char* psz, size_t n) const

Converts from UTF-8 encoding to Unicode. Returns the size of the destination buffer.

### wxMBConvUTF8::WC2MB

size_t WC2MB(char* buf, const wchar_t* psz, size_t n) const

Converts from Unicode to UTF-8 encoding. Returns the size of the destination buffer.