added code for optimized handling of UTF-8 locales: some string operations are more efficient under it and it's possible to completely compile-out support for other locales if the target system is known to only use UTF-8 locales

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45782 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-05-03 11:05:04 +00:00
parent d1f6e2cfe2
commit 111d99489d
10 changed files with 329 additions and 110 deletions

View File

@@ -41,10 +41,15 @@ wxUniChar::value_type wxUniChar::From8bit(char c)
if ( (unsigned char)c < 0x80 )
return c;
#if wxUSE_UTF8_LOCALE_ONLY
wxFAIL_MSG( _T("invalid UTF-8 character") );
return wxT('?'); // FIXME-UTF8: what to use as failure character?
#else
wchar_t buf[2];
if ( wxConvLibc.ToWChar(buf, 2, &c, 1) != 2 )
return wxT('?'); // FIXME-UTF8: what to use as failure character?
return buf[0];
#endif
}
/* static */
@@ -54,11 +59,16 @@ char wxUniChar::To8bit(wxUniChar::value_type c)
if ( c < 0x80 )
return c;
#if wxUSE_UTF8_LOCALE_ONLY
wxFAIL_MSG( _T("character cannot be converted to single UTF-8 byte") );
return '?'; // FIXME-UTF8: what to use as failure character?
#else
wchar_t in = c;
char buf[2];
if ( wxConvLibc.FromWChar(buf, 2, &in, 1) != 2 )
return '?'; // FIXME-UTF8: what to use as failure character?
return buf[0];
#endif
}