Update of /cvsroot/mahogany/M/src/modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4125/src/modules
Modified Files:
BareBonesEditor.cpp
Log Message:
use GuessUnicodeCharset() to try to find the charset in which to return UTF-8 data
from composer
Index: BareBonesEditor.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/BareBonesEditor.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -b -u -2 -r1.32 -r1.33
--- BareBonesEditor.cpp 16 Jul 2004 23:54:30 -0000 1.32
+++ BareBonesEditor.cpp 2 Oct 2004 16:44:05 -0000 1.33
@@ -329,50 +329,4 @@
// ----------------------------------------------------------------------------
-// some global helper functions
-// ----------------------------------------------------------------------------
-
-#if wxUSE_WCHAR_T && defined(OS_WIN)
-
-// this very simple minded function tries to determine the encoding we should
-// use from the given Unicode character code (http://www.unicode.org/charts/)
-static wxFontEncoding GetEncoding(wchar_t wch)
-{
- // basic latin
- if ( wch < 0x7f )
- return wxFONTENCODING_SYSTEM;
-
- // latin-1 supplement
- if ( wch < 0x100 )
- return wxFONTENCODING_CP1252;
-
- // greek
- if ( wch >= 0x370 && wch < 0x400 )
- return wxFONTENCODING_CP1253;
-
- // cyrillic
- if ( wch >= 0x400 && wch < 0x530 )
- return wxFONTENCODING_CP1251;
-
- // hebrew
- if ( wch >= 0x590 && wch < 0x600 )
- return wxFONTENCODING_CP1255;
-
- // arabic
- if ( wch >= 0x600 && wch < 0x700 )
- return wxFONTENCODING_CP1255;
-
- // unknown
- return wxFONTENCODING_UTF8;
-}
-
-static bool CanConvert(wxFontEncoding encIn, wxFontEncoding encOut)
-{
- return
- wxEncodingConverter::GetAllEquivalents(encIn).Index(encOut) != wxNOT_FOUND;
-}
-
-#endif // wxUSE_WCHAR_T
-
-// ----------------------------------------------------------------------------
// FormattedParagraph
// ----------------------------------------------------------------------------
@@ -1257,4 +1211,7 @@
// ----------------------------------------------------------------------------
+// from strutil.cpp
+extern wxFontEncoding GuessUnicodeCharset(const wchar_t *pwz);
+
EditorContentPart *BareBonesEditor::GetFirstPart()
{
@@ -1269,5 +1226,8 @@
for ( const wchar_t *pwc = wbuf; *pwc; pwc++ )
{
- const wxFontEncoding encThis = GetEncoding(*pwc);
+ static wchar_t wbuf2[2] = { L'\0', L'\0' };
+ wbuf2[0] = *pwc;
+
+ const wxFontEncoding encThis = GuessUnicodeCharset(wbuf2);
if ( encThis != wxFONTENCODING_SYSTEM && encThis != encPart )
{
@@ -1327,5 +1287,6 @@
// is it possible to convert to the desired encoding?
wxEncodingConverter conv;
- if ( CanConvert(encPart, m_encoding) &&
+ if ( wxEncodingConverter::GetAllEquivalents(encPart).
+ Index(m_encoding) != wxNOT_FOUND &&
conv.Init(encPart, m_encoding) )
{
@@ -1369,5 +1330,5 @@
//
// VZ: see above (FIXME)
- return new EditorContentPart(strutil_enforceCRLF(text), encPart);
+ return new EditorContentPart(strutil_enforceCRLF(text), m_encoding);
}
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates