X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstringcodec%2Fiso646fi.cpp;h=0db1d00485df6d553241e27db47fd3176c9fb031;hb=7c452691dffbc1f0a7d51a9e96d04f50e47fda3f;hp=ee7705b36898caec0af5d5b81724076828a8559a;hpb=02794ef3620d0d9cc3b8f1c0d8f2995c825fdf4f;p=libs%2Fcore.git diff --git a/source/stringcodec/iso646fi.cpp b/source/stringcodec/iso646fi.cpp index ee7705b..0db1d00 100644 --- a/source/stringcodec/iso646fi.cpp +++ b/source/stringcodec/iso646fi.cpp @@ -30,7 +30,7 @@ void Iso646Fi::Encoder::encode_char(unichar ch, string &buf) { int tch = transform_mapping_or_direct(mapping, map_size, ch, false); if(tch<0 || tch>0x7F) - error(ch, buf, "Can't express character in ISO-646-FI"); + error(ch, buf, invalid_character(ch, "ISO-646-FI")); else buf += tch; } @@ -44,16 +44,14 @@ void Iso646Fi::Encoder::transliterate(unichar, string &buf) unichar Iso646Fi::Decoder::decode_char(const string &str, string::const_iterator &i) { if(i==str.end()) - return error("No input"); + return -1; unsigned char ch = *i; - int tch = (ch<=0x7F ? transform_mapping_or_direct(mapping, map_size, ch, true) : -1); - unichar result; - if(tch==-1) - result = error("Undefined ISO-646-FI character"); + if(ch>=0x80) + result = error(invalid_sequence(i, i+1, "undefined ISO-646-FI character")); else - result = tch; + result = transform_mapping_or_direct(mapping, map_size, ch, true); ++i; return result;