-// ============================================================================
-// MBConv
-// ============================================================================
-
-WXDLLEXPORT_DATA(wxMBConv *) wxConvCurrent = &wxConvLibc;
-#if !wxUSE_WCHAR_T
-WXDLLEXPORT_DATA(wxMBConv) wxConvLibc, wxConvFile;
-#endif
-
-#if wxUSE_WCHAR_T
-
-// ----------------------------------------------------------------------------
-// standard libc conversion
-// ----------------------------------------------------------------------------
-
-WXDLLEXPORT_DATA(wxMBConv) wxConvLibc;
-
-size_t wxMBConv::MB2WC(wchar_t *buf, const char *psz, size_t n) const
-{
- return wxMB2WC(buf, psz, n);
-}
-
-size_t wxMBConv::WC2MB(char *buf, const wchar_t *psz, size_t n) const
-{
- return wxWC2MB(buf, psz, n);
-}
-
-// ----------------------------------------------------------------------------
-// standard file conversion
-// ----------------------------------------------------------------------------
-
-WXDLLEXPORT_DATA(wxMBConvFile) wxConvFile;
-
-// just use the libc conversion for now
-size_t wxMBConvFile::MB2WC(wchar_t *buf, const char *psz, size_t n) const
-{
- return wxMB2WC(buf, psz, n);
-}
-
-size_t wxMBConvFile::WC2MB(char *buf, const wchar_t *psz, size_t n) const
-{
- return wxWC2MB(buf, psz, n);
-}
-
-// ----------------------------------------------------------------------------
-// standard gdk conversion
-// ----------------------------------------------------------------------------
-
-#ifdef __WXGTK12__
-WXDLLEXPORT_DATA(wxMBConvGdk) wxConvGdk;
-
-#include <gdk/gdk.h>
-
-size_t wxMBConvGdk::MB2WC(wchar_t *buf, const char *psz, size_t n) const
-{
- if (buf) {
- return gdk_mbstowcs((GdkWChar *)buf, psz, n);
- } else {
- GdkWChar *nbuf = new GdkWChar[n=strlen(psz)];
- size_t len = gdk_mbstowcs(nbuf, psz, n);
- delete [] nbuf;
- return len;
- }
-}
-
-size_t wxMBConvGdk::WC2MB(char *buf, const wchar_t *psz, size_t n) const
-{
- char *mbstr = gdk_wcstombs((GdkWChar *)psz);
- size_t len = mbstr ? strlen(mbstr) : 0;
- if (buf) {
- if (len > n) len = n;
- memcpy(buf, psz, len);
- if (len < n) buf[len] = 0;
- }
- return len;
-}
-#endif // GTK > 1.0
-
-// ----------------------------------------------------------------------------
-// UTF-7
-// ----------------------------------------------------------------------------
-
-WXDLLEXPORT_DATA(wxMBConvUTF7) wxConvUTF7;
-
-#if 0
-static char utf7_setD[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789'(),-./:?";
-static char utf7_setO[]="!\"#$%&*;<=>@[]^_`{|}";
-static char utf7_setB[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789+/";
-#endif
-
-// TODO: write actual implementations of UTF-7 here
-size_t wxMBConvUTF7::MB2WC(wchar_t *buf, const char *psz, size_t n) const
-{
- return 0;
-}
-
-size_t wxMBConvUTF7::WC2MB(char *buf, const wchar_t *psz, size_t n) const
-{
- return 0;
-}
-
-// ----------------------------------------------------------------------------
-// UTF-8
-// ----------------------------------------------------------------------------
-
-WXDLLEXPORT_DATA(wxMBConvUTF8) wxConvUTF8;
-
-static unsigned long utf8_max[]={0x7f,0x7ff,0xffff,0x1fffff,0x3ffffff,0x7fffffff,0xffffffff};
-
-size_t wxMBConvUTF8::MB2WC(wchar_t *buf, const char *psz, size_t n) const
-{
- size_t len = 0;
-
- while (*psz && ((!buf) || (len<n))) {
- unsigned char cc=*psz++, fc=cc;
- unsigned cnt;
- for (cnt=0; fc&0x80; cnt++) fc<<=1;
- if (!cnt) {
- // plain ASCII char
- if (buf) *buf++=cc;
- len++;
- } else {
- cnt--;
- if (!cnt) {
- // invalid UTF-8 sequence
- return (size_t)-1;
- } else {
- unsigned ocnt=cnt-1;
- unsigned long res=cc&(0x3f>>cnt);
- while (cnt--) {
- cc = *psz++;
- if ((cc&0xC0)!=0x80) {
- // invalid UTF-8 sequence
- return (size_t)-1;
- }
- res=(res<<6)|(cc&0x3f);
- }
- if (res<=utf8_max[ocnt]) {
- // illegal UTF-8 encoding
- return (size_t)-1;
- }
- if (buf) *buf++=res;
- len++;
- }
- }
- }
- if (buf && (len<n)) *buf = 0;
- return len;
-}
-
-size_t wxMBConvUTF8::WC2MB(char *buf, const wchar_t *psz, size_t n) const
-{
- size_t len = 0;
-
- while (*psz && ((!buf) || (len<n))) {
- unsigned long cc=(*psz++)&0x7fffffff;
- unsigned cnt;
- for (cnt=0; cc>utf8_max[cnt]; cnt++);
- if (!cnt) {
- // plain ASCII char
- if (buf) *buf++=cc;
- len++;
- } else {
- len+=cnt+1;
- if (buf) {
- *buf++=(-128>>cnt)|((cc>>(cnt*6))&(0x3f>>cnt));
- while (cnt--)
- *buf++=0x80|((cc>>(cnt*6))&0x3f);
- }
- }
- }
- if (buf && (len<n)) *buf = 0;
- return len;
-}
-
-// ----------------------------------------------------------------------------
-// specified character set
-// ----------------------------------------------------------------------------
-
-class wxCharacterSet