+
+ // this function is used in the implementation of cMB2WC() to distinguish
+ // between the following cases:
+ //
+ // a) var width encoding with strings terminated by a single NUL
+ // (usual multibyte encodings): return 1 in this case
+ // b) fixed width encoding with 2 bytes/char and so terminated by
+ // 2 NULs (UTF-16/UCS-2 and variants): return 2 in this case
+ // c) fixed width encoding with 4 bytes/char and so terminated by
+ // 4 NULs (UTF-32/UCS-4 and variants): return 4 in this case
+ //
+ // anything else is not supported currently and -1 should be returned
+ virtual size_t GetMBNulLen() const { return 1; }
+
+ // return the maximal value currently returned by GetMBNulLen() for any
+ // encoding
+ static size_t GetMaxMBNulLen() { return 4 /* for UTF-32 */; }
+
+#if wxUSE_UNICODE_UTF8
+ // return true if the converter's charset is UTF-8, i.e. char* strings
+ // decoded using this object can be directly copied to wxString's internal
+ // storage without converting to WC and than back to UTF-8 MB string
+ virtual bool IsUTF8() const { return false; }
+#endif
+
+ // The old conversion functions. The existing classes currently mostly
+ // implement these ones but we're in transition to using To/FromWChar()
+ // instead and any new classes should implement just the new functions.
+ // For now, however, we provide default implementation of To/FromWChar() in
+ // this base class in terms of MB2WC/WC2MB() to avoid having to rewrite all
+ // the conversions at once.
+ //
+ // On success, the return value is the length (i.e. the number of
+ // characters, not bytes) not counting the trailing NUL(s) of the converted
+ // string. On failure, (size_t)-1 is returned. In the special case when
+ // outputBuf is NULL the return value is the same one but nothing is
+ // written to the buffer.
+ //
+ // Note that outLen is the length of the output buffer, not the length of
+ // the input (which is always supposed to be terminated by one or more
+ // NULs, as appropriate for the encoding)!
+ virtual size_t MB2WC(wchar_t *out, const char *in, size_t outLen) const;
+ virtual size_t WC2MB(char *out, const wchar_t *in, size_t outLen) const;
+
+
+ // make a heap-allocated copy of this object
+ virtual wxMBConv *Clone() const = 0;
+
+ // virtual dtor for any base class
+ virtual ~wxMBConv();
+};
+
+// ----------------------------------------------------------------------------
+// wxMBConvLibc uses standard mbstowcs() and wcstombs() functions for
+// conversion (hence it depends on the current locale)
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_BASE wxMBConvLibc : public wxMBConv
+{
+public:
+ virtual size_t MB2WC(wchar_t *outputBuf, const char *psz, size_t outputSize) const;
+ virtual size_t WC2MB(char *outputBuf, const wchar_t *psz, size_t outputSize) const;
+
+ virtual wxMBConv *Clone() const { return new wxMBConvLibc; }
+
+#if wxUSE_UNICODE_UTF8
+ virtual bool IsUTF8() const { return wxLocaleIsUtf8; }
+#endif