- !cmap.Eof();
- line = cmap.GetNextLine()) {
- // wxFprintf(stderr,_T("line contents: %s\n"),line.c_str());
- wxStringTokenizer token(line);
- wxString cmd = token.GetNextToken();
- if (cmd == comchar) {
- if (token.GetNextToken() == _T("alias"))
- cset->names.Add(token.GetNextToken());
- }
- else if (cmd == _T("<code_set_name>"))
- cset->names.Add(token.GetNextToken());
- else if (cmd == _T("<comment_char>"))
- comchar = token.GetNextToken();
- else if (cmd == _T("<escape_char>"))
- escchar = token.GetNextToken();
- else if (cmd == _T("<mb_cur_min>")) {
- delete cset;
- cset = (wxCharacterSet *) NULL;
- break; // we don't support multibyte charsets ourselves (yet)
- }
- else if (cmd == _T("CHARMAP")) {
- cset->data = (wchar_t *)calloc(256, sizeof(wchar_t));
- in_charset = TRUE;
- }
- else if (cmd == _T("END")) {
- if (token.GetNextToken() == _T("CHARMAP"))
- in_charset = FALSE;
- }
- else if (in_charset) {
- // format: <NUL> /x00 <U0000> NULL (NUL)
- // <A> /x41 <U0041> LATIN CAPITAL LETTER A
- wxString hex = token.GetNextToken();
- // skip whitespace (why doesn't wxStringTokenizer do this?)
- while (wxIsEmpty(hex) && token.HasMoreTokens()) hex = token.GetNextToken();
- wxString uni = token.GetNextToken();
- // skip whitespace again
- while (wxIsEmpty(uni) && token.HasMoreTokens()) uni = token.GetNextToken();
-
- if ((hex.Len() > 2) && (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));
- if (pos>=0) {
- unsigned long uni1 = ::wxHexToDec(uni.Mid(2,2));
- unsigned long uni2 = ::wxHexToDec(uni.Mid(4,2));
- cset->data[pos] = (uni1 << 16) | uni2;
- // wxFprintf(stderr,_T("char %02x mapped to %04x (%c)\n"),pos,cset->data[pos],cset->data[pos]);
- }
- }
- }
+ !cmap.Eof();
+ line = cmap.GetNextLine()) {
+ // wxFprintf(stderr,_T("line contents: %s\n"),line.c_str());
+ wxStringTokenizer token(line);
+ wxString cmd = token.GetNextToken();
+ if (cmd == comchar) {
+ if (token.GetNextToken() == _T("alias"))
+ cset->names.Add(token.GetNextToken());
+ }
+ else if (cmd == _T("<code_set_name>"))
+ cset->names.Add(token.GetNextToken());
+ else if (cmd == _T("<comment_char>"))
+ comchar = token.GetNextToken();
+ else if (cmd == _T("<escape_char>"))
+ escchar = token.GetNextToken();
+ else if (cmd == _T("<mb_cur_min>")) {
+ delete cset;
+ cset = (wxCharacterSet *) NULL;
+ break; // we don't support multibyte charsets ourselves (yet)
+ }
+ else if (cmd == _T("CHARMAP")) {
+ cset->data = (wchar_t *)calloc(256, sizeof(wchar_t));
+ in_charset = TRUE;
+ }
+ else if (cmd == _T("END")) {
+ if (token.GetNextToken() == _T("CHARMAP"))
+ in_charset = FALSE;
+ }
+ else if (in_charset) {
+ // format: <NUL> /x00 <U0000> NULL (NUL)
+ // <A> /x41 <U0041> LATIN CAPITAL LETTER A
+ wxString hex = token.GetNextToken();
+ // skip whitespace (why doesn't wxStringTokenizer do this?)
+ while (wxIsEmpty(hex) && token.HasMoreTokens()) hex = token.GetNextToken();
+ wxString uni = token.GetNextToken();
+ // skip whitespace again
+ while (wxIsEmpty(uni) && token.HasMoreTokens()) uni = token.GetNextToken();
+ if ((hex.Len() > 2) && (wxString(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));
+ if (pos>=0) {
+ unsigned long uni1 = ::wxHexToDec(uni.Mid(2,2));
+ unsigned long uni2 = ::wxHexToDec(uni.Mid(4,2));
+ cset->data[pos] = (uni1 << 16) | uni2;
+ // wxFprintf(stderr,_T("char %02x mapped to %04x (%c)\n"),pos,cset->data[pos],cset->data[pos]);
+ }
+ }
+ }