Contents Up Previous Next

wxMBConv

This class is the base class of a hierarchy of classes capable of converting text strings between multibyte (SBCS or DBCS) encodings and Unicode. It is itself a wrapper around the standard libc mbstowcs() and wcstombs() routines, and has one predefined instance, wxConvLibc.

Derived from

No base class

Include files

<wx/strconv.h>

See also

wxCSConv, wxEncodingConverter, wxMBConv classes overview

Members

wxMBConv::wxMBConv
wxMBConv::MB2WC
wxMBConv::WC2MB
wxMBConv::cMB2WC
wxMBConv::cWC2MB
wxMBConv::cMB2WX
wxMBConv::cWX2MB
wxMBConv::cWC2WX
wxMBConv::cWX2WC


wxMBConv::wxMBConv

wxMBConv()

Constructor.


wxMBConv::MB2WC

virtual size_t MB2WC(wchar_t *outputBuf, const char *psz, size_t outputSize) const

Converts from a string psz in multibyte encoding to Unicode putting the output into the buffer outputBuf of the maximum size outputSize (in wide characters, not bytes). If outputBuf is NULL, only the length of the string which would result from the conversion is calculated and returned. Note that this is the length and not size, i.e. the returned value does not include the trailing NUL. But when the function is called with a non-NULL outputBuf, the outputSize parameter should be the size of the buffer and so it should take into account the trailing NUL.

Parameters

outputBuf

psz

outputSize

Return value

The length of the converted string (in wide characters, excluding the NUL)


wxMBConv::WC2MB

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

Converts from Unicode to multibyte encoding. The semantics of this function (including the return value meaning) is the same as for MB2WC.

Notice that when the function is called with a non-NULL buffer, the n parameter should be the size of the buffer and so it should take into account the trailing NUL, which might take two or four bytes for some encodings (UTF-16 and UTF-32).


wxMBConv::cMB2WC

const wxWCharBuffer cMB2WC(const char* psz) const

Converts from multibyte encoding to Unicode by calling MB2WC, allocating a temporary wxWCharBuffer to hold the result.


wxMBConv::cWC2MB

const wxCharBuffer cWC2MB(const wchar_t* psz) const

Converts from Unicode to multibyte encoding by calling WC2MB, allocating a temporary wxCharBuffer to hold the result.


wxMBConv::cMB2WX

const char* cMB2WX(const char* psz) const

const wxWCharBuffer cMB2WX(const char* psz) const

Converts from multibyte encoding to the current wxChar type (which depends on whether wxUSE_UNICODE is set to 1). If wxChar is char, it returns the parameter unaltered. If wxChar is wchar_t, it returns the result in a wxWCharBuffer. The macro wxMB2WXbuf is defined as the correct return type (without const).


wxMBConv::cWX2MB

const char* cWX2MB(const wxChar* psz) const

const wxCharBuffer cWX2MB(const wxChar* psz) const

Converts from the current wxChar type to multibyte encoding. If wxChar is char, it returns the parameter unaltered. If wxChar is wchar_t, it returns the result in a wxCharBuffer. The macro wxWX2MBbuf is defined as the correct return type (without const).


wxMBConv::cWC2WX

const wchar_t* cWC2WX(const wchar_t* psz) const

const wxCharBuffer cWC2WX(const wchar_t* psz) const

Converts from Unicode to the current wxChar type. If wxChar is wchar_t, it returns the parameter unaltered. If wxChar is char, it returns the result in a wxCharBuffer. The macro wxWC2WXbuf is defined as the correct return type (without const).


wxMBConv::cWX2WC

const wchar_t* cWX2WC(const wxChar* psz) const

const wxWCharBuffer cWX2WC(const wxChar* psz) const

Converts from the current wxChar type to Unicode. If wxChar is wchar_t, it returns the parameter unaltered. If wxChar is char, it returns the result in a wxWCharBuffer. The macro wxWX2WCbuf is defined as the correct return type (without const).