X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fascii.cpp;h=6ffaf9a1facf2a3a1b0eac6da90d3578aa482639;hp=10eb7949b713d14e49d621b568cd205760a21aa7;hb=9da6abdcabec59f4845da256a8ad75a810ed1589;hpb=58384e355b4a78730d69243f1092e47591f2f384 diff --git a/source/ascii.cpp b/source/ascii.cpp index 10eb794..6ffaf9a 100644 --- a/source/ascii.cpp +++ b/source/ascii.cpp @@ -1,14 +1,24 @@ +/* $Id$ + +This file is part of libmspstrings +Copyright © 2006-2007 Mikko Rasa +Distributed under the LGPL +*/ + #include "ascii.h" 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 +26,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