]> git.tdb.fi Git - libs/core.git/blobdiff - source/stringcodec/jisx0201.cpp
Additional adjustments for Poller
[libs/core.git] / source / stringcodec / jisx0201.cpp
index d5987e596b39f10cca85297f977fdbdd617afc40..4c8cd4804901e0332a4b458f51bf2dbc79b27857 100644 (file)
@@ -3,9 +3,9 @@
 using namespace std;
 
 namespace Msp {
-namespace Codecs {
+namespace StringCodec {
 
-void JisX0201::Encoder::encode_char(UnicodeChar ch, string &buf)
+void JisX0201::Encoder::encode_char(unichar ch, string &buf)
 {
        if(ch>=0 && ch<=0x7F && ch!=0x5C && ch!=0x7E)
                buf += ch;
@@ -16,22 +16,22 @@ void JisX0201::Encoder::encode_char(UnicodeChar ch, string &buf)
        else if(ch>=0xFF61 && ch<=0xFF9F)
                buf += ch-0xFEC0;
        else
-               error(ch, buf, "Can't express character in JIS X 0201");
+               error(ch, buf, invalid_character(ch, "JIS X 0201"));
 }
 
-void JisX0201::Encoder::transliterate(UnicodeChar, string &buf)
+void JisX0201::Encoder::transliterate(unichar, string &buf)
 {
        buf += '?';
 }
 
 
-UnicodeChar JisX0201::Decoder::decode_char(const string &str, string::const_iterator &i)
+unichar JisX0201::Decoder::decode_char(const string &str, string::const_iterator &i)
 {
        if(i==str.end())
-               return error("No input");
+               return -1;
 
        unsigned char ch = *i;
-       UnicodeChar result;
+       unichar result;
        if(ch==0x5C)
                result = 0xA5;
        else if(ch==0x7E)
@@ -41,11 +41,11 @@ UnicodeChar JisX0201::Decoder::decode_char(const string &str, string::const_iter
        else if(ch>=0xA1 && ch<=0xDF)
                result = ch+0xFEC0;
        else
-               result = error("Undefined JIS X 0201 character");
+               result = error(invalid_sequence(i, i+1, "undefined JIS X 0201 character"));
 
        ++i;
        return result;
 }
 
-} // namespace Codecs
+} // namespace StringCodec
 } // namespace Msp