X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstringcodec%2Fiso2022jp.cpp;h=296c1efe1ed479bd930a8b7f768d87b9a970d010;hp=1e5bf90ee590fb068276a1287e3b0fe5c3a9f4ff;hb=f24e7b96e76b63c9b9b8a6bce4c7a9db64276ea8;hpb=3e3868860d4f4ca1bbe55fbf271c804307cea3c9 diff --git a/source/stringcodec/iso2022jp.cpp b/source/stringcodec/iso2022jp.cpp index 1e5bf90..296c1ef 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"); } } @@ -89,7 +91,7 @@ unichar Iso2022Jp::Decoder::decode_char(const string &str, string::const_iterato while(i!=str.end()) { - string::const_iterator j = i; + auto j = i; unichar result = -1; if(*j==033) @@ -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;