wxLoadCharacterSets() now appears to work (was a bit slow, but since it's
not called until someone actually uses wxConv_local, it should not affect too many). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2191 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1937,27 +1937,25 @@ static void wxLoadCharacterSets(void)
|
|||||||
|
|
||||||
if (already_loaded) return;
|
if (already_loaded) return;
|
||||||
|
|
||||||
#if defined(__UNIX__) && wxUSE_UNICODE
|
#if defined(__UNIX__)
|
||||||
// search through files in /usr/share/i18n/charmaps
|
// search through files in /usr/share/i18n/charmaps
|
||||||
wxString fname;
|
wxString fname;
|
||||||
printf("Commencing load\n");
|
|
||||||
for (fname = ::wxFindFirstFile(_T("/usr/share/i18n/charmaps/*"));
|
for (fname = ::wxFindFirstFile(_T("/usr/share/i18n/charmaps/*"));
|
||||||
!fname.IsEmpty();
|
!fname.IsEmpty();
|
||||||
fname = ::wxFindNextFile()) {
|
fname = ::wxFindNextFile()) {
|
||||||
wxPrintf(_("Loading: %s\n"), fname.c_str());
|
|
||||||
wxTextFile cmap(fname);
|
wxTextFile cmap(fname);
|
||||||
if (cmap.Open()) {
|
if (cmap.Open()) {
|
||||||
wxCharacterSet *cset = new wxCharacterSet;
|
wxCharacterSet *cset = new wxCharacterSet;
|
||||||
wxString comchar,escchar;
|
wxString comchar,escchar;
|
||||||
bool in_charset = FALSE;
|
bool in_charset = FALSE;
|
||||||
|
|
||||||
wxPrintf(_T("yup, loaded %s\n"),fname.c_str());
|
// wxFprintf(stderr,_T("Loaded: %s\n"),fname.c_str());
|
||||||
|
|
||||||
wxString line;
|
wxString line;
|
||||||
for (line = cmap.GetFirstLine();
|
for (line = cmap.GetFirstLine();
|
||||||
!cmap.Eof();
|
!cmap.Eof();
|
||||||
line = cmap.GetNextLine()) {
|
line = cmap.GetNextLine()) {
|
||||||
wxPrintf(_T("line contents: %s\n"),line.c_str());
|
// wxFprintf(stderr,_T("line contents: %s\n"),line.c_str());
|
||||||
wxStringTokenizer token(line);
|
wxStringTokenizer token(line);
|
||||||
wxString cmd = token.GetNextToken();
|
wxString cmd = token.GetNextToken();
|
||||||
if (cmd == comchar) {
|
if (cmd == comchar) {
|
||||||
@@ -1974,12 +1972,13 @@ static void wxLoadCharacterSets(void)
|
|||||||
comchar = token.GetNextToken();
|
comchar = token.GetNextToken();
|
||||||
else if (cmd == _T("<escape_char>"))
|
else if (cmd == _T("<escape_char>"))
|
||||||
escchar = token.GetNextToken();
|
escchar = token.GetNextToken();
|
||||||
else if (cmd == _T("<mb_cur_min")) {
|
else if (cmd == _T("<mb_cur_min>")) {
|
||||||
delete cset;
|
delete cset;
|
||||||
goto forget_it; // we don't support multibyte charsets ourselves (yet)
|
cset = (wxCharacterSet *) NULL;
|
||||||
|
break; // we don't support multibyte charsets ourselves (yet)
|
||||||
}
|
}
|
||||||
else if (cmd == _T("CHARMAP")) {
|
else if (cmd == _T("CHARMAP")) {
|
||||||
cset->data = (wchar_t *)calloc(256, sizeof(wxChar));
|
cset->data = (wchar_t *)calloc(256, sizeof(wchar_t));
|
||||||
in_charset = TRUE;
|
in_charset = TRUE;
|
||||||
}
|
}
|
||||||
else if (cmd == _T("END")) {
|
else if (cmd == _T("END")) {
|
||||||
@@ -1988,19 +1987,31 @@ static void wxLoadCharacterSets(void)
|
|||||||
}
|
}
|
||||||
else if (in_charset) {
|
else if (in_charset) {
|
||||||
// format: <NUL> /x00 <U0000> NULL (NUL)
|
// format: <NUL> /x00 <U0000> NULL (NUL)
|
||||||
|
// <A> /x41 <U0041> LATIN CAPITAL LETTER A
|
||||||
wxString hex = token.GetNextToken();
|
wxString hex = token.GetNextToken();
|
||||||
|
// skip whitespace (why doesn't wxStringTokenizer do this?)
|
||||||
|
while (wxIsEmpty(hex) && token.HasMoreTokens()) hex = token.GetNextToken();
|
||||||
wxString uni = token.GetNextToken();
|
wxString uni = token.GetNextToken();
|
||||||
// just assume that we've got the right format
|
// skip whitespace again
|
||||||
|
while (wxIsEmpty(uni) && token.HasMoreTokens()) uni = token.GetNextToken();
|
||||||
|
|
||||||
|
if ((hex.GetChar(0) == escchar) && (hex.GetChar(1) == _T('x')) &&
|
||||||
|
(uni.Left(2) == _T("<U"))) {
|
||||||
|
hex.MakeUpper(); uni.MakeUpper();
|
||||||
int pos = ::wxHexToDec(hex.Mid(2,2));
|
int pos = ::wxHexToDec(hex.Mid(2,2));
|
||||||
|
if (pos>=0) {
|
||||||
unsigned long uni1 = ::wxHexToDec(uni.Mid(2,2));
|
unsigned long uni1 = ::wxHexToDec(uni.Mid(2,2));
|
||||||
unsigned long uni2 = ::wxHexToDec(uni.Mid(4,2));
|
unsigned long uni2 = ::wxHexToDec(uni.Mid(4,2));
|
||||||
cset->data[pos] = (uni1 << 16) | uni2;
|
cset->data[pos] = (uni1 << 16) | uni2;
|
||||||
|
// wxFprintf(stderr,_T("char %02x mapped to %04x (%c)\n"),pos,cset->data[pos],cset->data[pos]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cset) {
|
||||||
cset->names.Shrink();
|
cset->names.Shrink();
|
||||||
wxCharsets.Add(cset);
|
wxCharsets.Add(cset);
|
||||||
forget_it:
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user