#include <string.h>
#include <stdlib.h>
+
+#include "wx/debug.h"
+#include "wx/strconv.h"
+#include "wx/intl.h"
+#include "wx/log.h"
+
+// ----------------------------------------------------------------------------
+// globals
+// ----------------------------------------------------------------------------
+
+WXDLLEXPORT_DATA(wxMBConv *) wxConvCurrent = &wxConvLibc;
+
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+#if wxUSE_WCHAR_T
+
#ifdef __SALFORDC__
#include <clib.h>
#endif
#include <windows.h>
#endif
-#include "wx/debug.h"
-#include "wx/strconv.h"
-#include "wx/intl.h"
-#include "wx/log.h"
-
#define BSWAP_UCS4(str, len) { unsigned _c; for (_c=0; _c<len; _c++) str[_c]=wxUINT32_SWAP_ALWAYS(str[_c]); }
#define BSWAP_UTF16(str, len) { unsigned _c; for (_c=0; _c<len; _c++) str[_c]=wxUINT16_SWAP_ALWAYS(str[_c]); }
#error "Weird sizeof(wchar_t): please report your platform details to wx-users mailing list"
#endif
-// ----------------------------------------------------------------------------
-// globals
-// ----------------------------------------------------------------------------
-
-WXDLLEXPORT_DATA(wxMBConv *) wxConvCurrent = &wxConvLibc;
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-#if wxUSE_WCHAR_T
#ifdef WC_UTF16
size_t outbuf = n;
size_t res, cres;
- wchar_t *tmpbuf;
+ wchar_t *tmpbuf = 0;
if (g_wcNeedsSwap)
{
size_t WC2MB(char *buf, const wchar_t *psz, size_t n)
{
-#if defined(__BORLANDC__) && (__BORLANDC__ > 0x530)
+#if ( defined(__BORLANDC__) && (__BORLANDC__ > 0x530) ) \
+ || ( defined(__MWERKS__) && defined(__WXMSW__) )
size_t inbuf = std::wcslen(psz);
#else
size_t inbuf = ::wcslen(psz);
return m_cset->WC2MB(buf, psz, n);
// latin-1 (direct)
-#if defined(__BORLANDC__) && (__BORLANDC__ > 0x530)
+#if ( defined(__BORLANDC__) && (__BORLANDC__ > 0x530) ) \
+ || ( defined(__MWERKS__) && defined(__WXMSW__) )
size_t len=std::wcslen(psz);
#else
size_t len=::wcslen(psz);