Your file doesn't contain the binary you think it does. ascii2uni
isn't encoding the way you expect it to; I'm not sure why.
echo "0x82BE" | ascii2uni -a X > test1 od -tx1 test1 0000000 e8 8a be 0a
(Note that echo -n
does the same thing. The newline 0a
is coming from ascii2uni
, not echo
.)
Converting this with iconv
:
iconv -f SHIFT-JIS -t UTF-8 test1 > test2 od -tx1 test2 0000000 e9 97 83 ef bd be 0a cat test2 闃セ
Which is what you got. (Note also that in your ascii2uni example, you had 82BE
, which is だ in Shift-JIS, instead of your original 0x82ae
, which is ぐ. I'll stick with 82BE
.)
The problem is that the binary wasn't right to begin with. Do it this way:
echo -en '\x82\xbe' > test3 od -tx1 test3 0000000 82 be iconv -f SHIFT-JIS -t UTF-8 test3 > test4 od -tx1 test4 0000000 e3 81 a0 cat test4 だ