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

If you are editing a file encoded as latin1, you will find that ‘fileencoding’ for that buffer is set to latin1. So you will need to manually set the fileencoding before saving the file.

:set fileencoding=utf8
:w myfilename

Also note that UTF8 files often begin with a Byte Order Mark (BOM) which indicates endianness. The BOM is optional but some programs use it exclusively to determine the file encoding. Under certain conditions Vim will write the BOM but sometimes it won’t. To explicitly set the BOM do this:

:set bomb

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)