#module
#deffunc jistoeuc val, val
mref euc, 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
code.0 += 0x80
code.1 += 0x80
wpoke euc, cnt, (code.1 << 8) + code.0
i += 2
continue cnt + 2
}
// 1バイト文字
poke euc, cnt, code.0
i++
loop
return
#global
sdim string, 3200, 2 // 足りない場合はサイズを大きくしてください
sdim file, 512
// 読込
dialog "txt", 16, "Jisコードテキスト"
if stat = 0 : end
notesel string.0
noteload refstr
// 保存
dialog "txt", 17, "Eucコードテキスト"
if stat = 0 : end
jistoeuc string.1, string.0
notesel string.1
notesave refstr
dialog "JISコードからEUCコードに変換しました。"
|