From d46eb009c132b555761b95e6ac3318539dddb20e Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Tue, 31 Jan 2017 23:06:43 +0900 Subject: use multibytetowidechar to convert charset --- win32/winfont.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'win32/winfont.c') diff --git a/win32/winfont.c b/win32/winfont.c index 4632d51..fb98ccd 100644 --- a/win32/winfont.c +++ b/win32/winfont.c @@ -11,7 +11,7 @@ struct font_win32 { uint8_t buf[16]; }; - +/* #include "jisunih.h" uint16_t jis2unih(uint8_t jis) { @@ -26,7 +26,15 @@ uint16_t jis2unih(uint8_t jis) { return jis; } } - +*/ +uint16_t jis2unih(uint8_t jis) { + uint16_t wbuf[2]; + int outchar = MultiByteToWideChar(932, MB_ERR_INVALID_CHARS, + (char *)&jis, 1, (wchar_t *)wbuf, 2); + if (!outchar) return 0; + return wbuf[0]; +} +/* #include "jisuni.h" uint16_t jis2uni(uint16_t jis) { @@ -40,6 +48,16 @@ uint16_t jis2uni(uint16_t jis) { } return 0; } +*/ +uint16_t jis2uni(uint16_t jis) { + uint16_t sjis = jis2sjis(jis); + uint8_t abuf[2] = {sjis>>8, sjis}; + uint16_t wbuf[2]; + int outchar = MultiByteToWideChar(932, MB_ERR_INVALID_CHARS, + (char *)abuf, 2, (wchar_t *)wbuf, 2); + if (!outchar) return 0; + return wbuf[0]; +} static const void *winfont_get(const struct fmdsp_font *font, uint16_t c, enum fmdsp_font_type type) { -- cgit v1.2.3