Changeset 1927


Ignore:
Timestamp:
02/08/01 13:17:33 (20 years ago)
Author:
sjboddie
Message:

Fixed a bug in the C++ encoding support - 8 bit encodings like windows-1251
were being treated as 16 bit encodings in some places

Location:
trunk/gsdl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/etc/main.cfg

    r1904 r1927  
    8989#              option is mandatory for all encoding lines except the
    9090#              special case for utf8.
     91# multibyte -- This optional argument should be set for all encodings that use
     92#              multibyte characters.
    9193
    9294# The utf8 encoding is handled internally and doesn't require a map file.
     
    125127
    126128# CJK encodings (note that Shift-JIS Japanese isn't currently supported)
    127 Encoding shortname=gbk "longname=Chinese Simplified (GBK)" map=gbk.ump
    128 Encoding shortname=big5 "longname=Chinese Traditional (Big5)" map=big5.ump
    129 Encoding shortname=euc-jp "longname=Japanese (EUC)" map=euc_jp.ump
    130 Encoding shortname=euc-kr "longname=Korean (UHC)" map=uhc.ump
     129Encoding shortname=gbk "longname=Chinese Simplified (GBK)" map=gbk.ump multibyte
     130Encoding shortname=big5 "longname=Chinese Traditional (Big5)" map=big5.ump multibyte
     131Encoding shortname=euc-jp "longname=Japanese (EUC)" map=euc_jp.ump multibyte
     132Encoding shortname=euc-kr "longname=Korean (UHC)" map=uhc.ump multibyte
    131133
    132134
  • trunk/gsdl/lib/gsdlunicode.cpp

    r1870 r1927  
    384384
    385385mapinconvertclass::mapinconvertclass () {
     386  multibyte = 0;
    386387  mapbuflen = 0;
    387388}
     
    425426      // got a complete character
    426427      if (charlen == 1) {
    427     // ascii character
    428     output.push_back (mapbuf[0]);
     428    if (mapbuf[0] < 0x80) {
     429      // ascii character
     430      output.push_back (mapbuf[0]);
     431    } else {
     432      output.push_back (converter.convert((unsigned short)mapbuf[0]));
     433    }
    429434
    430435      } else {
     
    448453
    449454mapoutconvertclass::mapoutconvertclass () {
     455  multibyte = 0;
    450456  mapbuflen=0;
    451457  mapbufhere=0;
     
    500506    } else {
    501507      outc = converter.convert (*texthere);
    502       mapbuf[0] = (unsigned char)(outc >> 8);
    503       mapbuf[1] = (unsigned char)(outc & 0xff);
    504       mapbuflen = 2;
     508      if (multibyte) {
     509        mapbuf[0] = (unsigned char)(outc >> 8);
     510        mapbuf[1] = (unsigned char)(outc & 0xff);
     511        mapbuflen = 2;
     512      } else {
     513        mapbuf[0] = outc;
     514        mapbuflen = 1;
     515      }
    505516    }
    506517      }
  • trunk/gsdl/lib/gsdlunicode.h

    r1870 r1927  
    153153  };
    154154
     155  void set_multibyte (int new_multibyte) {multibyte = new_multibyte;};
     156
    155157  void reset ();
    156158  void convert (text_t &output, status_t &status);
     
    160162  unsigned char mapbuf[MAXMAPCHARLEN];
    161163  size_t mapbuflen;
     164  int multibyte;
    162165
    163166  // note: multiple instances of mapinconvert class are expensive
     
    172175    if (mapbuflen == 0) return 0;
    173176    if (mapbuf[0] < 0x80) return 1;
     177    if (!multibyte) return 1;
    174178    return 2;
    175179  }
     
    194198  };
    195199
     200  void set_multibyte (int new_multibyte) {multibyte = new_multibyte;};
     201
    196202  void reset ();
    197203  void convert (char *output, size_t maxlen,
     
    202208  size_t mapbuflen;
    203209  size_t mapbufhere;
     210  int multibyte;
    204211
    205212  mapconvert converter;
  • trunk/gsdl/src/recpt/receptionist.cpp

    r1877 r1927  
    13001300
    13011301  text_t subkey, subvalue, shortname, longname, mapfile;
     1302  int multibyte = 0;
    13021303  text_t::const_iterator cfglinesub_here;
    13031304  text_tarray::const_iterator cfgline_here = cfgline.begin();
    13041305  text_tarray::const_iterator cfgline_end = cfgline.end();
    13051306  while (cfgline_here != cfgline_end) {
    1306     cfglinesub_here = getdelimitstr((*cfgline_here).begin(),
    1307                     (*cfgline_here).end(), '=', subkey);
    1308     if (subkey == "shortname") {
    1309       shortname = substr (cfglinesub_here, (*cfgline_here).end());
    1310     } else if (subkey == "longname") {
    1311       longname = substr (cfglinesub_here, (*cfgline_here).end());
    1312     } else if (subkey == "map") {
    1313       mapfile = substr (cfglinesub_here, (*cfgline_here).end());
     1307    if (*cfgline_here == "multibyte") {
     1308      multibyte = 1;
     1309    } else {
     1310      cfglinesub_here = getdelimitstr((*cfgline_here).begin(),
     1311                      (*cfgline_here).end(), '=', subkey);
     1312      if (subkey == "shortname") {
     1313    shortname = substr (cfglinesub_here, (*cfgline_here).end());
     1314      } else if (subkey == "longname") {
     1315    longname = substr (cfglinesub_here, (*cfgline_here).end());
     1316      } else if (subkey == "map") {
     1317    mapfile = substr (cfglinesub_here, (*cfgline_here).end());
     1318      }
    13141319    }
    13151320    cfgline_here++;
     
    13451350      mapinconvertclass *mapinconvert = new mapinconvertclass();
    13461351      mapinconvert->setmapfile (to_uc_map, 0x003F);
     1352      mapinconvert->set_multibyte (multibyte);
    13471353      mapoutconvertclass *mapoutconvert = new mapoutconvertclass();
    13481354      mapoutconvert->setmapfile (from_uc_map, 0x3F);
     1355      mapoutconvert->set_multibyte (multibyte);
    13491356      mapoutconvert->set_rzws(1);
    13501357      add_converter (shortname, mapinconvert, mapoutconvert);
Note: See TracChangeset for help on using the changeset viewer.