From 8e1db641bb244980bc96ee9da4ba2f0dee8274ad Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 31 Oct 2021 14:45:57 +0200 Subject: [PATCH] Fix JIS X 0208 encoding This seems to have broken all the way back in f47bc86. --- source/core/refptr.h | 2 +- source/stringcodec/jisx0208.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) 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; -- 2.45.2