Update of /cvsroot/mahogany/M/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24629/src/gui
Modified Files:
wxMApp.cpp
Log Message:
try to convert using wxCSConv classes (which use iconv and so are more powerful
and also always support conversion to UTF-8 unlike wxEncodingConverter) before
falling back to wxEncodingConverter in EnsureAvailableTextEncoding()
Index: wxMApp.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMApp.cpp,v
retrieving revision 1.302
retrieving revision 1.303
diff -b -u -2 -r1.302 -r1.303
--- wxMApp.cpp 16 Jan 2006 20:32:27 -0000 1.302
+++ wxMApp.cpp 13 Feb 2006 00:12:19 -0000 1.303
@@ -2505,9 +2505,34 @@
// try to find another encoding
wxFontEncoding encAlt;
- if ( wxFontMapper::Get()->GetAltForEncoding(*enc, &encAlt,
wxEmptyString, mayAskUser) )
+ if ( wxFontMapper::Get()->
+ GetAltForEncoding(*enc, &encAlt, wxEmptyString, mayAskUser) )
{
// translate the text (if any) to the equivalent encoding
- if ( text )
+ if ( text && !text->empty() )
{
+#if wxUSE_WCHAR_T
+ // try converting via Unicode
+ wxCSConv a2w(*enc);
+ wxWCharBuffer wbuf(a2w.cMB2WC(text->c_str()));
+ if ( *wbuf )
+ {
+ // special case of UTF-8 which is used all the time under wxGTK
+ if ( encAlt == wxFONTENCODING_UTF8 )
+ {
+ *text = wxConvUTF8.cWC2MB(wbuf);
+ }
+ else // all the other encodings, use generic converter
+ {
+ wxCSConv w2a(encAlt);
+ *text = w2a.cWC2MB(wbuf);
+ }
+
+ if ( !text->empty() )
+ return true;
+ //else: fall back to wxEncodingConverter
+ }
+ //else: conversion to Unicode failed
+#endif // wxUSE_WCHAR_T
+
wxEncodingConverter conv;
if ( !conv.Init(*enc, encAlt) )
@@ -2523,5 +2548,5 @@
*enc = encAlt;
}
- else //no equivalent encoding
+ else // no equivalent encoding
{
return false;
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates