-
Notifications
You must be signed in to change notification settings - Fork 0
/
jis2euc.rb
29 lines (26 loc) · 932 Bytes
/
jis2euc.rb
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
class Jis2euc
def conv(instr)
ary = instr.bytes.to_a
outstr = ""
i = 0
kanji = false
while i < ary.length
if ary[i] == 0x1B
if ary[i+1] == 0x24 && ary[i+2] == 0x42
kanji = true
elsif ary[i+1] == 0x28 && ary[i+2] == 0x42
kanji = false
end
i += 3
next
end
if kanji
outstr += (ary[i]+128).chr
else
outstr += ary[i].chr
end
i += 1
end
return outstr
end
end