I was using xxd to look at the hex of a utf-16le file with
byte-order-mark.  I noticed that converting from the hex form back to text
just left my buffer empty.

It seems that this is because the fileencoding causes the filter   %!xxd -r
 to pass utf-16le text to xxd.  However, xxd quite reasonably seems to
expect the hex dump to be in ascii, (or EBCDIC!).

Thinking about what vim ought to do in general for handling encoding of
shell filters makes my head hurt!  However, at least the requirements for
xxd are a known quantity.

Although I don't know how often I will run into this problem, I have
currently solved it for myself with the following in my vimrc:

fun! s:unhexify()
    let l:fenc = &fileencoding
    setlocal fileencoding=latin1
    :%!xxd -r
    exe 'setlocal fileencoding='.l:fenc
endfun
com! Xxd :%!xxd
com! XxdR :call s:unhexify()


Is this a solid approach to the problem, and is it worth working something
like this into the vim runtime files?

- Gabriel

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui