]> git.tdb.fi Git - libs/core.git/blobdiff - source/stringcodec/iso646fi.cpp
Put unichar and ustring in their own file
[libs/core.git] / source / stringcodec / iso646fi.cpp
index b6aa883df43f387c553564552b79243a060aa4c7..64e429d4197a648349edbda2f8bc88d5df070454 100644 (file)
@@ -26,7 +26,7 @@ const int mapping[map_size*2]=
 namespace Msp {
 namespace StringCodec {
 
-void Iso646Fi::Encoder::encode_char(UnicodeChar ch, string &buf)
+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)
@@ -35,25 +35,23 @@ void Iso646Fi::Encoder::encode_char(UnicodeChar ch, string &buf)
                buf += tch;
 }
 
-void Iso646Fi::Encoder::transliterate(UnicodeChar, string &buf)
+void Iso646Fi::Encoder::transliterate(unichar, string &buf)
 {
        buf += '?';
 }
 
 
-UnicodeChar Iso646Fi::Decoder::decode_char(const string &str, string::const_iterator &i)
+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);
-
-       UnicodeChar result;
-       if(tch==-1)
+       unichar result;
+       if(ch>=0x80)
                result = error("Undefined ISO-646-FI character");
        else
-               result = tch;
+               result = transform_mapping_or_direct(mapping, map_size, ch, true);
 
        ++i;
        return result;