From: Mikko Rasa Date: Sun, 31 Oct 2021 12:45:57 +0000 (+0200) Subject: Fix JIS X 0208 encoding X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=commitdiff_plain;h=8e1db641bb244980bc96ee9da4ba2f0dee8274ad Fix JIS X 0208 encoding This seems to have broken all the way back in f47bc86. --- diff --git a/source/core/refptr.h b/source/core/refptr.h index 21da15d..70cb176 100644 --- a/source/core/refptr.h +++ b/source/core/refptr.h @@ -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); } diff --git a/source/stringcodec/jisx0208.cpp b/source/stringcodec/jisx0208.cpp index c097824..df28a37 100644 --- a/source/stringcodec/jisx0208.cpp +++ b/source/stringcodec/jisx0208.cpp @@ -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(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;