Guido Milanese wrote:
I have an additional question concerning this topic, that has been discussed
several times.
I am happily using (g)vim with files containing several languages, basically
as editor for LaTeX, and it's all right with Unicode. I am working in Linux
Mandriva 2007, with (g)vim 7.0.30.
I still have a minor problem. My default encoding is Unicode-utf8: the .vimrc
file says "set encoding=utf8". The automatic conversion from latin1 to utf8
is perfect. However, sometimes, for reasons of compatibility with other
programs that still cannot read Unicode files (e.g. LyX) I must leave
the "latin1" encoding of some files unchanged. What I do is:
1. open gvim
2: set encoding=latin1
3: e: filename.txt
4. work and save the file, that this way remains in its original encoding.
OR
:e ++enc=latin1 filename.txt
Question:
Is there any difference among the two systems?
Is the original encoding affected in some way by one of the two approaches?
Thanks!
gm
------------
Guido Milanese
http://www.arsantiqua.org
The difference is as follows:
With your method #1, gvim represents all the data of all files internally
using the Latin1 encoding. There is no conversion, but if you have files in
other windows, or in hidden buffers, which are not in Latin1, it's anyone's
guess what might happen to them.
With your method #2, gvim keeps UTF-8 for the internal representation of data.
Conversion happens on reading and writing; that conversion is lossless and
doesn't require an external utility such as iconv, because Vim "knows" that
the codepoints U+0000 to U+00FF of Unicode correspond one-to-one and
respectively to the characters 0x00 to 0xFF of Latin1. There may be a slight
"swelling" of the data in memory, depending on the proportion of accented and
other upper-ascii characters in your file, since codepoints U+0080 to U+00FF
occupy two bytes each in memory (while U+0000 to U+007F are one byte each).
Normally you can afford that swelling. All in all, I would regard this method
as "safer" because any other files (in other windows or in hidden buffers)
won't suffer: this method sets the 'fileencoding' of this particular file to
Latin1 (as with ":setlocal fenc=latin1"), but other buffers (if any) are not
affected.
Best regards,
Tony.
--
Hummingbirds never remember the words to songs.