Thursday, July 29, 2010

Re: Editing files full of NUL characters

Hi Bob!

On Do, 29 Jul 2010, Bob Weissman wrote:

> I've used (g)vim for many years, but don't often exercise its
> more exotic functions. I work on a Windcows PC, but lately I find
> myself wanting to edit files from other sources, like the iPhone.
>
> 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.
>
> 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?

That looks like UTF-16 or UCS2. Try to reload the file using:

:e ++enc=utf-16 your_file

You might need to try several encodings (like utf-16be or utf-16le ( Big
endian versus little endian byte order). May be there are more
alternatives, I have only seen these kind of files very rarely and
utf-16 usually worked for me.

See the help :h ++enc and :help 'fileencoding'

regards,
Christian

--
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