diff options
author | Takamichi Horikawa <takamichiho@gmail.com> | 2017-01-31 23:06:43 +0900 |
---|---|---|
committer | Takamichi Horikawa <takamichiho@gmail.com> | 2017-01-31 23:06:43 +0900 |
commit | d46eb009c132b555761b95e6ac3318539dddb20e (patch) | |
tree | c5a89c651e32e263482d53c1ee4cca44bcb58066 /win32/winfont.c | |
parent | 92ac7de6585e64006db631d6c39d4a7ef00f4776 (diff) |
use multibytetowidechar to convert charset
Diffstat (limited to 'win32/winfont.c')
-rw-r--r-- | win32/winfont.c | 22 |
1 files changed, 20 insertions, 2 deletions
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) { |