X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fascii.cpp;h=43f7053173a21e1ac5cc3b79bc3cdad3def303de;hp=10eb7949b713d14e49d621b568cd205760a21aa7;hb=d2118ac101602cfe2d62fb7deb6ef3fcb0fe137b;hpb=dbda1bb7f44f289c9f1c5ba9741970ac264d8e5d diff --git a/source/ascii.cpp b/source/ascii.cpp index 10eb794..43f7053 100644 --- a/source/ascii.cpp +++ b/source/ascii.cpp @@ -4,11 +4,14 @@ using namespace std; namespace Msp { -void Ascii::Encoder::encode_char(wchar_t c) +void Ascii::Encoder::encode_char(wchar_t c_) { + // Win32 has typedef unsigned short wchar_t + int c=c_; if(c<0 || c>0x7F) - throw CodecError("Can't express character in ASCII"); - append(c); + error("Can't express character in ASCII"); + else + append(c); } @@ -16,9 +19,13 @@ void Ascii::Decoder::decode_char(const string &str, string::const_iterator &i) { if(i==str.end()) return; - if(*i&0x80) - throw CodecError("Invalid ASCII string (undefined character)"); - append(*i++); + else if(*i&0x80) + { + error("Invalid ASCII string (undefined character)"); + ++i; + } + else + append(*i++); } } // namespace Msp