]> git.tdb.fi Git - libs/core.git/blobdiff - source/ascii.cpp
Add copyright notices and Id tags
[libs/core.git] / source / ascii.cpp
index 10eb7949b713d14e49d621b568cd205760a21aa7..6ffaf9a1facf2a3a1b0eac6da90d3578aa482639 100644 (file)
@@ -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