X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstringcodec%2Fiso646fi.cpp;h=64e429d4197a648349edbda2f8bc88d5df070454;hb=93bb92bad766d269a6bac87e00020a6158531739;hp=100ce1313f699a441e13b0f88795ef3e192b5dbf;hpb=b42ed73a1b241c0e93ee03c43c4584b41c549bac;p=libs%2Fcore.git diff --git a/source/stringcodec/iso646fi.cpp b/source/stringcodec/iso646fi.cpp index 100ce13..64e429d 100644 --- a/source/stringcodec/iso646fi.cpp +++ b/source/stringcodec/iso646fi.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspstrings -Copyright © 2006-2007 Mikko Rasa -Distributed under the LGPL -*/ - #include "codecutils.h" #include "iso646fi.h" @@ -31,9 +24,9 @@ const int mapping[map_size*2]= namespace Msp { -namespace Codecs { +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) @@ -42,29 +35,27 @@ 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; } -} // namespace Codecs +} // namespace StringCodec } // namespace Msp