X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstringcodec%2Fiso2022jp.cpp;h=ebfe5f79acd210f61b7159900b0129ab899517a4;hp=985451280f42cfd79496963a95716dd59b3d717d;hb=242a4a9abe1e1113b5eb39aa751aa054f696d7be;hpb=02794ef3620d0d9cc3b8f1c0d8f2995c825fdf4f diff --git a/source/stringcodec/iso2022jp.cpp b/source/stringcodec/iso2022jp.cpp index 9854512..ebfe5f7 100644 --- a/source/stringcodec/iso2022jp.cpp +++ b/source/stringcodec/iso2022jp.cpp @@ -35,12 +35,14 @@ void Iso2022Jp::Encoder::encode_char(unichar ch, string &buf) { Kuten jis = ucs_to_jisx0208(ch); if(!jis) - return error(ch, buf, "Can't express character in ISO-2022-JP"); + return error(ch, buf, invalid_character(ch, "ISO-2022-JP")); if(mode!=JISX0208) switch_mode(JISX0208, buf); - char jbuf[2] = {jis.ku+0x20, jis.ten+0x20}; + char jbuf[2]; + jbuf[0] = jis.ku+0x20; + jbuf[1] = jis.ten+0x20; buf.append(jbuf, 2); } } @@ -64,7 +66,7 @@ void Iso2022Jp::Encoder::switch_mode(Mode m, string &buf) case ASCII: buf.append("\033(B", 3); break; case JISX0201: buf.append("\033(J", 3); break; case JISX0208: buf.append("\033$B", 3); break; - default: throw CodecError("WTF? Invalid mode in Iso2022Jp::Encoder::switch_mode"); + default: throw invalid_argument("Iso2022Jp::Encoder::switch_mode"); } } @@ -85,7 +87,7 @@ Iso2022Jp::Decoder::Decoder(ErrorMode em): unichar Iso2022Jp::Decoder::decode_char(const string &str, string::const_iterator &i) { if(i==str.end()) - return error("No input"); + return -1; while(i!=str.end()) { @@ -121,7 +123,7 @@ unichar Iso2022Jp::Decoder::decode_char(const string &str, string::const_iterato else if(dec) return dec->decode_char(str, i); else - throw CodecError("WTF? No sub-decoder for Iso2022Jp::Decoder"); + throw logic_error("no sub-decoder"); if(result>=0) return result;