Wednesday, December 2, 2009

Re: Windows Registry Editor text files (.REG) in Unicode (?) encoding - displayed as garbage

On 2 Dec 2009 at 22:25, Christian Brabandt wrote:
>
> On Mi, 02 Dez 2009, Frantisek Rysanek wrote:
>
> > The problem is that Regedit in XP exports Unicode (or what), maybe
> > utf-16 (or some other multibyte charset). If I try "edit with Vim" on
> > such files, I get a screenful of garbage.
>
> I believe Windows uses a UTF-16 encoding, so try reloading the file with
> :e! ++enc=utf-16le
>
Thanks for that tip :-)
When I did just that, VIM responded something like "couldn't
convert".
But once I added "set enc=utf-16le" to my _vimrc, suddenly it started
to work :-) I'll probably add that to syntax/registry.vim or
someplace like that (oh wait - chicken & egg problem looming?)

On 3 Dec 2009 at 2:58, Linda W wrote:
>
> The reg files are "Little-endian UTF-16 Unicode with CRLF line
> terminators", with vim showing their encoding as "utf-16le".
>
> If you do a 'set' command, you should see fileencodings set to:
>
> fileencodings=ucs-bom,utf-8,default,latin1
>
> It's important that the "ucs-bom" is before the utf-8 or vim won't
> detect bom files correctly.
>
Allright, in my case, I'm more likely to see encodings such as ISO
latin2 or CP1250, so I've added this line into my systemwide _vimrc:
set fileencodings=ucs-bom,utf-8,default,latin2,cp1250

But that line doesn't seem to have any effect.
The enc=utf-16le alone does have the desired effect though :-)

The correct loading of the REG file in UTF-16le seems to have an
interesting side effect. My install of Gvim seems to talk to me in
Czech, probably based on some Windows locale. And, with enc=utf-16le,
the result messages from VIM get the nationalized characters garbled
(printed as hexa codes), while the buffer being edited is displayed
just right (even if the buffer contains 8bit cp1250 text). I tried
forcing "helplang" from cs to en (in _vimrc), but that didn't help
:-)
It's not very bad, but if you had a further pointer on how to set
that straight, please let me know :-)

Yes, I'm using GVIM, from the default Windows build downloaded off
gvim.org as a binary installer package. I've written some snippets of
code in Mingw before, but I'm not up to rolling my own Windows build
of VIM :-) I just don't bother. Come to think of that, the only thing
I changed in the default install is the _vimrc (deleted the original
and replaced with something left over from the past).
Maybe that's where I should've started :-)

Thank you both, Chris and Linda...

Frank Rysanek

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: