Thursday, July 29, 2010

Re: Editing files full of NUL characters

* 2010-07-29 09:50 (-0700), Bob Weissman wrote:

> Often, the files look like they ought to be text files but are full of
> NULs. Instead of "Hello", I will see "H^@e^@l^@l^@o^@". Or maybe it's
> "^@H^@e^@l^@l^@o". I haven't figured out the byte order.

Looks like an UTF-16 encoded file.

> Is there a way to edit these files in gvim such that the ^@'s don't
> appear onscreen but get written properly when I write the files back?

You could try opening the file with

:e ++enc=utf-16be file.txt

or with ++enc=utf-16le if the byte order wasn't correct.

But Vim should detect the encoding correctly if (1) the file has byte
order mark (U+FFFE or U+FEFF) in the beginning and (2) you have ucs-bom
in 'fileencodings' option.

:set fileencodings=ucs-bom,utf-8,default,latin1

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment