#module
#deffunc euctojis val, val
mref jis, 24 : mref euc, 25
wbite = 0 // 2バイト文字フラグ
i = 0 // 読込元インデクス
strlen len, euc
repeat len
peek code.0, euc, cnt
// 2バイト文字
if code.0 >= 0xa1 & (code.0 <= 0xfe) {
// 2バイト開始エスケープシーケンス(KI)
if wbite = 0 {
wbite = 1
poke jis, i + 0, 0x1b
poke jis, i + 1, 0x24
poke jis, i + 2, 0x42
i += 3
}
// コード変換
code.0 -= 0x80
peek code.1, euc, cnt + 1
code.1 -= 0x80
wpoke jis, i, (code.1 << 8) + code.0
i += 2
continue cnt + 2
}
// 2バイト終了エスケープシーケンス(KO)
if wbite {
wbite = 0
poke jis, i + 0, 0x1b
poke jis, i + 1, 0x28
poke jis, i + 2, 0x42
i += 3
}
// 1バイト文字
poke jis, i, code.0
i++
loop
return
#global
sdim string, 3200, 2 // 足りない場合はサイズを大きくしてください
sdim file, 512
// 読込
dialog "txt", 16, "Eucコードテキスト"
if stat = 0 : end
notesel string.0
noteload refstr
// 保存
dialog "txt", 17, "Jisコードテキスト"
if stat = 0 : end
euctojis string.1, string.0
notesel string.1
notesave refstr
dialog "EUCコードからJISコードに変換しました。"
end
|