[Vim] Easy Fixing File Encoding
I have received some files from Japanese clients and have trouble with reading it through Vim, it looks like a mess:
Check the file by $ file -bi
command, and it returns:
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
:
References
- Shift JIS and Code page 932 on Wikipedia.
- Vim Tips Wiki
⤧ Previous post Fuzzy text searching and case insensitive matching in Oracle database ⤧ Next post [SQL] 字串連接的妙用