X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstringcodec%2Fwindows1252.cpp;h=a6bde2407bad5cdcb5fa3a2cb458b911b0ebd9b5;hp=33527e4c92c3fea8df76276a04562f7f9c546450;hb=HEAD;hpb=967785734be5c3fc6f75da122c2d93ebbb338271 diff --git a/source/stringcodec/windows1252.cpp b/source/stringcodec/windows1252.cpp index 33527e4..a6bde24 100644 --- a/source/stringcodec/windows1252.cpp +++ b/source/stringcodec/windows1252.cpp @@ -16,9 +16,9 @@ unsigned short table[32]= namespace Msp { -namespace Codecs { +namespace StringCodec { -void Windows1252::Encoder::encode_char(UnicodeChar ch, string &buf) +void Windows1252::Encoder::encode_char(unichar ch, string &buf) { if((ch>=0 && ch<=0x7F) || (ch>=0xA0 && ch<=0xFF)) buf += ch; @@ -31,28 +31,28 @@ void Windows1252::Encoder::encode_char(UnicodeChar ch, string &buf) return; } - error(ch, buf, "Can't express character in Windows-1252"); + error(ch, buf, invalid_character(ch, "Windows-1252")); } } -void Windows1252::Encoder::transliterate(UnicodeChar, string &buf) +void Windows1252::Encoder::transliterate(unichar, string &buf) { buf += '?'; } -UnicodeChar Windows1252::Decoder::decode_char(const string &str, string::const_iterator &i) +unichar Windows1252::Decoder::decode_char(const string &str, string::const_iterator &i) { if(i==str.end()) - return error("No input"); + return -1; int ch = static_cast(*i); - UnicodeChar result; + unichar result; if(ch>=0x80 && ch<=0x9F) { result = table[ch-0x80]; if(result==0) - result = error("Undefined Windows-1252 character"); + result = error(invalid_sequence(i, i+1, "undefined Windows-1252 character")); } else result = ch; @@ -61,5 +61,5 @@ UnicodeChar Windows1252::Decoder::decode_char(const string &str, string::const_i return result; } -} // namespace Codecs +} // namespace StringCodec } // namespace Msp