-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.lua
50 lines (44 loc) · 1.62 KB
/
sample.lua
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
-----------------------------------------------
-- Sample of UTF8toSJIS.lua for W4.00.03
-- Copyright (c) 2019, Saya
-- All rights reserved.
-- 2019/04/21 rev.0.01
-----------------------------------------------
function chkBreak(n)
sleep(n or 0)
if fa.sharedmemory("read", 0x00, 0x01, "") == "!" then
error("Break!",2)
end
end
fa.sharedmemory("write", 0x00, 0x01, "-")
function script_path()
local str = debug.getinfo(2, "S").source:sub(2)
return str:match("(.*/)")
end
-- main
local myDir = script_path()
local libDir = myDir.."lib/"
local UTF8toSJIS = require(libDir .. "UTF8toSJIS")
local UTF8SJIS_table = "Utf8Sjis.tbl"
local SJIS_file = "sample_out.txt"
local strUTF8, strSJIS, sj_length
local str={
"UTF8→S-JIS 全角日本語漢字変換テスト表",
"、。〃¢‐ 一倅怎瀁耀退!¥熙~",
"※〒℃⇒⇔♪Ωαβγθπφ●○◎◆◇■□★☆", --よく使われる記号
"①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ", --JIS 13区文字
"㍉㌔㌢㍍㌘㌧㌃㌶㍑㍗㌍㌦㌣㌫㍊㌻㎜㎝㎞㎎㎏㏄㎡〝〟№㏍℡", --JIS 13区文字
"㊤㊥㊦㊧㊨㈱㈲㈹㍾㍽㍼㍻∮∑∟⊿∪∩∠⊥≡≒√∵∫", --JIS 13区文字
"半角/ABC 全角/ABC 半角カナ/アカサタナワヲン ガパ ァィゥェォャュョ"
}
local fhw = io.open(myDir..SJIS_file, "w")
local fht = io.open(myDir..UTF8SJIS_table, "r")
for i=1,#str do
strUTF8 = str[i]
strSJIS, sj_length = UTF8toSJIS:UTF8_to_SJIS_str_cnv(fht, strUTF8)
fhw:write(strSJIS, "\n")
chkBreak()
end
fhw:close()
fht:close()
return