Steve Hall <digitect@...
> On Sun, 2002-12-01 at 20:33, Srinath Avadhanula wrote:
> > Recently, I noticed that the behavior of a vim script file changes
> > based on what encoding the user is currently using. I tried reading
> > the encoding documentation briefly, but got lost quite quickly.
> > [snip]
> > Could someone explain? How can I get the same behavior from the script
> > file irrespective of what encoding the user is currently using?
> I just went through this with our scripts. I found that any character
> with a decimal value above 127 is asking for trouble outside of
> &encoding=latin1. So I started conditioning based on encoding whenever
> I want something "excessive":
> if &encoding == "latin1"
> let mybookmarksymbol = "»»"
> let mybookmarksymbol = "=>"
> A user on Chinese Windows said it cleared up all his multi-byte issues
> with our scripts (720K total).
> Steve Hall [ digitect(at)mindspring.com ]
Maybe it works for you, Steve, because you never use any single-byte
encoding other than Latin1. But if you write scripts for general
consumption, beware that the people using them might use any kind of
encodings, some of them single-byte (Latin1, Eastern Europe, Greek,
Cyrillic, ...) others multibyte (utf8, East-Asian).
The reason the script acts differently is that it is read according to the
current encoding settings (see section 34 of the Vim FAQ and my tip
); not only 'encoding'
but 'fileencoding' and 'fileencodings' are relevant here.
Maybe a modeline (:help modeline) in a Vim comment near the start of the
script, setting the 'fileencoding' locally for the script, would help; it's
not perfect though, since it has to be read before it is interpreted.