X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstringcodec%2Fiso885915.cpp;h=eb26264d8dd5bacd7d72bc481ffbad5632dc25c7;hp=3eccbcf91e436105d9b0e17e4367b13df3a659fe;hb=817e584903996a041692640720a5a272d847a3c7;hpb=b56eb5ec1da675da0c66abc53c1e4f6c4e4cccbd diff --git a/source/stringcodec/iso885915.cpp b/source/stringcodec/iso885915.cpp index 3eccbcf..eb26264 100644 --- a/source/stringcodec/iso885915.cpp +++ b/source/stringcodec/iso885915.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 "iso885915.h" @@ -30,41 +23,32 @@ const int mapping[map_size*2]= namespace Msp { -namespace Codecs { +namespace StringCodec { -void Iso885915::Encoder::encode_char(UnicodeChar ch, string &buf) +void Iso885915::Encoder::encode_char(unichar ch, string &buf) { int tch = transform_mapping_or_direct(mapping, map_size, ch, false); if(tch<0 || tch>0xFF) - error(ch, buf, "Can't express character in ISO-8859-15"); + error(ch, buf, invalid_character(ch, "ISO-8859-15")); else buf += tch; } -void Iso885915::Encoder::transliterate(UnicodeChar, string &buf) +void Iso885915::Encoder::transliterate(unichar, string &buf) { buf += '?'; } -UnicodeChar Iso885915::Decoder::decode_char(const string &str, string::const_iterator &i) +unichar Iso885915::Decoder::decode_char(const string &str, string::const_iterator &i) { if(i==str.end()) - return error("No input"); - - unsigned char ch = *i; - int tch = transform_mapping_or_direct(mapping, map_size, ch, true); - - UnicodeChar result; - if(tch==-1) - result = error("Undefined ISO-8859-15 character"); - else - result = tch; + return -1; - ++i; - return result; + unsigned char ch = *i++; + return transform_mapping_or_direct(mapping, map_size, ch, true); } -} // namespace Codecs +} // namespace StringCodec } // namespace Msp