+TECObjectRef s_TECNativeCToUnicode = NULL ;
+TECObjectRef s_TECUnicodeToNativeC = NULL ;
+TECObjectRef s_TECPCToNativeC = NULL ;
+TECObjectRef s_TECNativeCToPC = NULL ;
+void wxMacSetupConverters()
+{
+ // if we assume errors are happening here we need low level debugging since the high level assert will use the encoders that
+ // are not yet setup...
+
+ OSStatus status = noErr ;
+ status = TECCreateConverter(&s_TECNativeCToUnicode,
+ wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman, kTextEncodingUnicodeDefault);
+
+
+ status = TECCreateConverter(&s_TECUnicodeToNativeC,
+ kTextEncodingUnicodeDefault, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman);
+
+ if ( !wxApp::s_macDefaultEncodingIsPC )
+ {
+ status = TECCreateConverter(&s_TECPCToNativeC,
+ kTextEncodingWindowsLatin1, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman);
+
+
+ status = TECCreateConverter(&s_TECNativeCToPC,
+ wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman , kTextEncodingWindowsLatin1 );
+ }
+}
+
+void wxMacCleanupConverters()
+{
+ OSStatus status = noErr ;
+ status = TECDisposeConverter(s_TECNativeCToUnicode);
+
+ status = TECDisposeConverter(s_TECUnicodeToNativeC);
+
+ status = TECDisposeConverter(s_TECPCToNativeC);
+
+ status = TECDisposeConverter(s_TECNativeCToPC);
+}
+
+wxWCharBuffer wxMacStringToWString( const wxString &from )
+{
+#if wxUSE_UNICODE
+ wxWCharBuffer result( from.wc_str() ) ;
+#else
+ OSStatus status = noErr ;
+ ByteCount byteOutLen ;
+ ByteCount byteInLen = from.Length() ;
+ ByteCount byteBufferLen = byteInLen *2 ;
+ wxWCharBuffer result( from.Length() ) ;
+ status = TECConvertText(s_TECNativeCToUnicode, (ConstTextPtr)from.c_str() , byteInLen, &byteInLen,
+ (TextPtr)result.data(), byteBufferLen, &byteOutLen);
+ result.data()[byteOutLen/2] = 0 ;
+#endif
+ return result ;
+}
+
+wxString wxMacMakeStringFromCString( const char * from , int len )
+{
+ OSStatus status = noErr ;
+ wxString result ;
+ wxChar* buf = result.GetWriteBuf( len ) ;
+#if wxUSE_UNICODE
+ ByteCount byteOutLen ;
+ ByteCount byteInLen = len ;
+ ByteCount byteBufferLen = len *2 ;
+
+ status = TECConvertText(s_TECNativeCToUnicode, (ConstTextPtr)from , byteInLen, &byteInLen,
+ (TextPtr)buf, byteBufferLen, &byteOutLen);
+#else
+ if ( wxApp::s_macDefaultEncodingIsPC )
+ memcpy( buf , from , len ) ;
+ else
+ {
+ OSStatus status = noErr ;
+ ByteCount byteOutLen ;
+ ByteCount byteInLen = len ;
+ ByteCount byteBufferLen = byteInLen ;
+
+ status = TECConvertText(s_TECNativeCToPC, (ConstTextPtr)from , byteInLen, &byteInLen,
+ (TextPtr)buf, byteBufferLen, &byteOutLen);
+ }
+#endif
+ buf[len] = 0 ;
+ result.UngetWriteBuf() ;
+ return result ;
+}
+
+wxString wxMacMakeStringFromCString( const char * from )