]> git.tdb.fi Git - libs/core.git/blobdiff - source/stringcodec/jisx0208.cpp
Put unichar and ustring in their own file
[libs/core.git] / source / stringcodec / jisx0208.cpp
index 6b46b1b679b5a94636e807d350510174eb0eb86f..411ae2b6477c945e5d5a95da14837e42863d2591 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of libmspstrings
-Copyright © 2006-2007 Mikko Rasa
-Distributed under the LGPL
-*/
-
 #include "jisx0208.h"
 
 #include "jisx0208.table"
@@ -12,9 +5,9 @@ Distributed under the LGPL
 using namespace std;
 
 namespace Msp {
-namespace Codecs {
+namespace StringCodec {
 
-void JisX0208::Encoder::encode_char(UnicodeChar ucs, string &buf)
+void JisX0208::Encoder::encode_char(unichar ucs, string &buf)
 {
        unsigned short jis = ucs_to_jisx0208(ucs);
        if(jis)
@@ -26,22 +19,22 @@ void JisX0208::Encoder::encode_char(UnicodeChar ucs, string &buf)
                error(ucs, buf, "Can't express character in JIS X 0208");
 }
 
-void JisX0208::Encoder::transliterate(UnicodeChar, string &buf)
+void JisX0208::Encoder::transliterate(unichar, string &buf)
 {
        buf.append("!)", 2);
 }
 
 
-UnicodeChar JisX0208::Decoder::decode_char(const string &str, string::const_iterator &i)
+unichar JisX0208::Decoder::decode_char(const string &str, string::const_iterator &i)
 {
        if(i==str.end())
-               return error("No input");
+               return -1;
 
        string::const_iterator j = i;
        Kuten jis;
        jis.ku = *j++-0x20;
 
-       UnicodeChar result;
+       unichar result;
        if(j==str.end())
                result = error("Incomplete JIS X 0208 character");
        else
@@ -57,7 +50,7 @@ UnicodeChar JisX0208::Decoder::decode_char(const string &str, string::const_iter
 }
 
 
-UnicodeChar jisx0208_to_ucs(Kuten jis)
+unichar jisx0208_to_ucs(Kuten jis)
 {
        if(jis.ku==0 || jis.ku>0x5E || jis.ten==0 || jis.ten>0x5E)
                return 0;
@@ -65,7 +58,7 @@ UnicodeChar jisx0208_to_ucs(Kuten jis)
        return jisx0208_to_ucs_table[jis.ku*94 + jis.ten - 95];
 }
 
-Kuten ucs_to_jisx0208(UnicodeChar c)
+Kuten ucs_to_jisx0208(unichar c)
 {
        if(c<0 || c>0xFFFF)
                return Kuten();
@@ -89,5 +82,5 @@ Kuten ucs_to_jisx0208(UnicodeChar c)
        return result;
 }
 
-} // namespace Codecs
+} // namespace StringCodec
 } // namespace Msp