1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
|
#module "sjis2utf8"
#uselib "kernel32"
#func _mb2wc "MultiByteToWideChar" int, int, sptr, int, sptr, int
#func _wc2mb "WideCharToMultiByte" int, int, sptr, int, sptr, int, int, int
#define CP_ACP 0
#define CP_UTF8 65001
#deffunc sjis2utf8n var dest, str src
len_uni = strlen(src) * 2
sdim str_uni, len_uni + 1
cnvstow str_uni, src
_wc2mb CP_UTF8, 0, varptr(str_uni), -1, 0, 0, 0, 0
len_utf8 = stat
memexpand dest, len_utf8 + 1
_wc2mb CP_UTF8, 0, varptr(str_uni), -1, varptr(dest), len_utf8, 0, 0
return len_utf8
#defcfunc utf8n2sjis var dest
_mb2wc CP_UTF8, 0, varptr(dest), -1, 0, 0
len_uni = stat
sdim str_uni, len_uni + 1
_mb2wc CP_UTF8, 0, varptr(dest), -1, varptr(str_uni), len_uni
return cnvwtos(str_uni)
#global
|