X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fjisx0208.cpp;h=e24673bf4cff30548cad58f4734e1dcbbfe3d574;hp=477ccd082c4d1516fa45dde8ccdbac6d474ab85e;hb=d2118ac101602cfe2d62fb7deb6ef3fcb0fe137b;hpb=ebd23ef7dde39a35e9ffdfb5be31934507cefaad diff --git a/source/jisx0208.cpp b/source/jisx0208.cpp index 477ccd0..e24673b 100644 --- a/source/jisx0208.cpp +++ b/source/jisx0208.cpp @@ -9,10 +9,13 @@ namespace Msp { void JisX0208::Encoder::encode_char(wchar_t ucs) { unsigned short jis=ucs_to_jisx0208(ucs); - if(!jis) throw CodecError("Can't express character in JIS X 0208"); - - char buf[2]={jis>>8, jis}; - append(buf, 2); + if(jis) + { + char buf[2]={jis>>8, jis}; + append(buf, 2); + } + else + error("Can't express character in JIS X 0208"); } @@ -30,19 +33,21 @@ void JisX0208::Decoder::decode_char(const string &str, string::const_iterator &i wchar_t ucs=jisx0208_to_ucs(high<<8 | *i++); high=0; - if(!ucs) - throw CodecError("Invalid JIS X 0208 string (undefined character)"); - - append(ucs); + if(ucs) + append(ucs); + else + error("Invalid JIS X 0208 string (undefined character)"); } void JisX0208::Decoder::sync() { if(high) - throw CodecError("Sync in middle of JIS X 0208 character"); + { + error("Sync in middle of JIS X 0208 character"); + high=0; + } } - wchar_t jisx0208_to_ucs(unsigned short jis) { if((jis&0xFF)<0x21 || (jis&0xFF)>0x7E || (jis&0xFF00)<0x2100 || (jis&0xFF00)>0x7E00)