]> git.tdb.fi Git - libs/core.git/commitdiff
Fix JIS X 0208 encoding
authorMikko Rasa <tdb@tdb.fi>
Sun, 31 Oct 2021 12:45:57 +0000 (14:45 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 31 Oct 2021 18:30:30 +0000 (20:30 +0200)
This seems to have broken all the way back in f47bc86.

source/core/refptr.h
source/stringcodec/jisx0208.cpp

index 21da15df6a21d2581f640e88245c969da5eb0f80..70cb17607361364de990f8828643f80af8d8da00 100644 (file)
@@ -81,7 +81,7 @@ public:
        T *get() const { return data; }
        T &operator*() const { return *data; }
        T *operator->() const { return data; }
-       operator bool() const { return data!=0; }
+       explicit operator bool() const { return data!=0; }
 
        unsigned refcount() const { return (data ? counts->count : 0); }
 
index c09782481537acd4a12a9cb342ce0997dfd20d1d..df28a376c10ff9760aafcee0cb84acd294c8fdde 100644 (file)
@@ -9,12 +9,12 @@ namespace StringCodec {
 
 void JisX0208::Encoder::encode_char(unichar ucs, string &buf)
 {
-       unsigned short jis = ucs_to_jisx0208(ucs);
+       Kuten jis = ucs_to_jisx0208(ucs);
        if(jis)
        {
                char jbuf[2];
-               jbuf[0] = jis>>8;
-               jbuf[1] = jis;
+               jbuf[0] = jis.ku+0x20;
+               jbuf[1] = jis.ten+0x20;
                buf.append(jbuf, 2);
        }
        else
@@ -79,8 +79,8 @@ Kuten ucs_to_jisx0208(unichar c)
        Kuten result;
        if(ucs_to_jisx0208_table[i].ucs==static_cast<unsigned short>(c))
        {
-               result.ku = (ucs_to_jisx0208_table[i].jis>>8)+1;
-               result.ten = ucs_to_jisx0208_table[i].jis+1;
+               result.ku = (ucs_to_jisx0208_table[i].jis>>8);
+               result.ten = ucs_to_jisx0208_table[i].jis;
        }
 
        return result;