X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstringcodec%2Fjisx0208.cpp;h=d56ec33d22a2da43bc6ff8b8bc1d6af30e549706;hb=1f0843257065789231a9949e0a81b79afd7bbebe;hp=411ae2b6477c945e5d5a95da14837e42863d2591;hpb=3e3868860d4f4ca1bbe55fbf271c804307cea3c9;p=libs%2Fcore.git diff --git a/source/stringcodec/jisx0208.cpp b/source/stringcodec/jisx0208.cpp index 411ae2b..d56ec33 100644 --- a/source/stringcodec/jisx0208.cpp +++ b/source/stringcodec/jisx0208.cpp @@ -16,7 +16,7 @@ void JisX0208::Encoder::encode_char(unichar ucs, string &buf) buf.append(jbuf, 2); } else - error(ucs, buf, "Can't express character in JIS X 0208"); + error(ucs, buf, invalid_character(ucs, "JIS X 0208")); } void JisX0208::Encoder::transliterate(unichar, string &buf) @@ -36,13 +36,15 @@ unichar JisX0208::Decoder::decode_char(const string &str, string::const_iterator unichar result; if(j==str.end()) - result = error("Incomplete JIS X 0208 character"); + result = error(invalid_sequence(i, j, "incomplete JIS X 0208 character")); else { jis.ten = *j++-0x20; result = jisx0208_to_ucs(jis); + if(result==-1) + result = error(invalid_sequence(i, j, "invalid JIS X 0208 ku-ten")); if(result==0) - result = error("Undefined JIS X 0208 character"); + result = error(invalid_sequence(i, j, "undefined JIS X 0208 character")); } i = j; @@ -53,7 +55,7 @@ unichar JisX0208::Decoder::decode_char(const string &str, string::const_iterator unichar jisx0208_to_ucs(Kuten jis) { if(jis.ku==0 || jis.ku>0x5E || jis.ten==0 || jis.ten>0x5E) - return 0; + return -1; return jisx0208_to_ucs_table[jis.ku*94 + jis.ten - 95]; }