]> git.tdb.fi Git - libs/core.git/blobdiff - source/stringcodec/windows1252.cpp
Add move semantics to Variant
[libs/core.git] / source / stringcodec / windows1252.cpp
index bbd67536348894552e9163a9aaae664878cdd60e..a6bde2407bad5cdcb5fa3a2cb458b911b0ebd9b5 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of libmspstrings
-Copyright © 2006-2007 Mikko Rasa
-Distributed under the LGPL
-*/
-
 #include "windows1252.h"
 
 using namespace std;
@@ -23,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;
@@ -38,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<unsigned char>(*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;
@@ -68,5 +61,5 @@ UnicodeChar Windows1252::Decoder::decode_char(const string &str, string::const_i
        return result;
 }
 
-} // namespace Codecs
+} // namespace StringCodec
 } // namespace Msp