#module
#deffunc jistosjis val, val
mref sjis, 24 : mref jis, 25
wbite = 0 // 2バイト文字フラグ
i = 0 // 読込元インデクス
strlen len, jis
repeat len
peek code.0, jis, i
// 制御文字
if code.0 = 0x1b {
peek code.0, jis, i + 1
peek code.1, jis, i + 2
if code.0 = 0x24 & (code.1 = 0x42) : wbite = 1 // 2バイト開始エスケープシーケンス(KI)
if code.0 = 0x28 & (code.1 = 0x42) : wbite = 0 // 2バイト終了エスケープシーケンス(KO)
i += 3
continue cnt
}
// 2バイト文字
if wbite {
peek code.1, jis, i + 1
if code.0 \ 2 {
code.0 = ((code.0 + 1) / 2) + 0x70
code.1 += 0x1f
} else {
code.0 = code.0 / 2 + 0x70
code.1 += 0x7d
}
if code.0 >= 0xa0 : code.0 += 0x40
if code.1 >= 0x7f : code.1++
wpoke sjis, cnt, (code.1 << 8) + code.0
i += 2
continue cnt + 2
}
// 1バイト文字
poke sjis, cnt, code.0
i++
loop
return
#global
sdim string, 3200, 2 // 足りない場合はサイズを大きくしてください
objsize winx, 25
button "読み込む", *load
mesbox string, winx, winy - 25, 5
stop
*load
dialog "txt", 16, "Jisコードテキスト"
if stat {
notesel string
noteload refstr
jistosjis string.1, string.0
objprm 1, string.1
}
stop
|