How can I use vim to convert my file to utf8?

I have a text file. I was told to make UTF8. How can I do this using Vim?

+75
vim utf-8
Feb 16 '12 at 11:13
source share
2 answers

If you are editing a file encoded as latin1, you will find that the "fileencoding" for this buffer is set to latin1. Therefore, before saving the file, you must manually install the file.

:set fileencoding=utf8 :w myfilename 

Also note that UTF8 files often start with a Byte Order (BOM) sign, which indicates accuracy. the specification is optional, but some programs use it solely to determine the encoding of the file. Under certain conditions, Vim will write a specification, but sometimes it will not. To explicitly establish a specification, do the following:

 :set bomb 

For more information :help mbyte-options and :help utf8 and :help bomb .

+109
Feb 16 '12 at 11:14
source share
 :w ++enc=utf-8 % 

to write a utf-8 encoded file to disk.

+28
Feb 16 '12 at 11:20
source share



All Articles