Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In order to make this conversion I have to use a text editor. This is tedious. Is there an easier way to do it, like some program I can run from the Linux or OSX terminal?

share|improve this question
    
If your target is Window's Shift_JIS, you should use CP932 instead if you are having problems converting some characters. – lepe Jun 6 '13 at 3:08
up vote 8 down vote accepted

To convert from Shift JIS to UTF-8 on linux just do:

iconv -f SHIFT-JIS -t UTF-8 <infile> > <outfile>

and to go the other way just reverse the arguments:

iconv -f UTF-8 -t SHIFT-JIS <infile> > <outfile>

I don't know OSX but it may well have the iconv command as well, in which case something similar should work.

share|improve this answer
    
iconv -f UTF-16 -t SHIFT-JIS part2errorfirst.txt > jjjjjjjjjj.txt is leading to garbled text- i.imgur.com/Z4H8v29.png – vipin8169 Apr 2 at 9:42
    
converted a file using iconv -f UTF-16 -t SHIFT_JIS prt1shift.txt > jjjjjjjjjj.txt, and instead of SHIFT_JIS it got converted into Western(ISO-8859-15) with all the JP characters converted to boxes – vipin8169 Apr 2 at 10:28

I use the following command:

SHIFT-JIS to UTF-8

nkf -w <infile> > <Outfile>

UTF-8 to SHIFT-JIS

nkf -s <infile> > <Outfile>

NKF - Network Kanji code conversion Filter

share|improve this answer
    
I am trying to convert a file in utf-8 to shift-JIS. But it doesn't work as expected. The resulting file has weird characters in it, instead of Japanense ones. All the JP characters are garbled - imgur.com/sbibRAT – vipin8169 Apr 2 at 9:34
    
converted a file using nkf -s prt1shift.txt > klklklklklk.txt, and instead of SHIFT_JIS it got converted into Western(ISO-8859-15) with all the JP characters converted to boxes – vipin8169 Apr 2 at 10:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.