Easy Fixing File Encoding (in Vim)

Steven C.
From Zen to Code
Published in
2 min readFeb 26, 2020

I have received some files from Japanese clients and have trouble with reading it through Vim, it looks like a mess:

The Shift-JIS encoded file looks like a mess in my Vim

Check the file by file -bicommand, and it returns:

file -bi command and return result

text/plain; charset=unknown-8bit

Fortunately, I’ve been informed that the file is encoded by Shift JIS, saved a hell lot of my time to figure out the encoding.

Shift JIS (Shift Japanese Industrial Standards, also SJIS, Shift_JIS) is a character encoding for the Japanese language, it has been replaced by CP932 for better compatibility in certain cases.

According to Vim Tips Wiki, one can reload a file using a different encoding if Vim was not able to detect the correct encoding.

So, here is the simple solution in Vim, just use :e ++enc=sjis or :e ++enc=cp932:

After reload the file by this command, it become readable

References

--

--

Steven C.
From Zen to Code

“Life’s like a movie, write your own ending.” — Jim Henson