]> git.tdb.fi Git - libs/core.git/blobdiff - source/stringcodec/iso646fi.cpp
Add move semantics to Variant
[libs/core.git] / source / stringcodec / iso646fi.cpp
index ee7705b36898caec0af5d5b81724076828a8559a..0db1d00485df6d553241e27db47fd3176c9fb031 100644 (file)
@@ -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;