X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstringcodec%2Fiso88591.cpp;fp=source%2Fstringcodec%2Fiso88591.cpp;h=064d4a76792eae33f12ee45a802187fc66a56750;hp=0000000000000000000000000000000000000000;hb=b42ed73a1b241c0e93ee03c43c4584b41c549bac;hpb=5b1368cb791cab043f0435628cacbaff36e39b7b diff --git a/source/stringcodec/iso88591.cpp b/source/stringcodec/iso88591.cpp new file mode 100644 index 0000000..064d4a7 --- /dev/null +++ b/source/stringcodec/iso88591.cpp @@ -0,0 +1,38 @@ +/* $Id$ + +This file is part of libmspstrings +Copyright © 2006-2007 Mikko Rasa +Distributed under the LGPL +*/ + +#include "iso88591.h" + +using namespace std; + +namespace Msp { +namespace Codecs { + +void Iso88591::Encoder::encode_char(UnicodeChar ch, string &buf) +{ + if(ch<0 || ch>0xFF) + return error(ch, buf, "Can't express character in ISO-8859-1"); + + buf += ch; +} + +void Iso88591::Encoder::transliterate(UnicodeChar, string &buf) +{ + buf += '?'; +} + + +UnicodeChar Iso88591::Decoder::decode_char(const string &str, string::const_iterator &i) +{ + if(i==str.end()) + return error("No input"); + + return static_cast(*i++); +} + +} // namespace Codecs +} // namespace Msp