Re: locale-*independent* vi editor supporting UTF-8

From: John Fieber (
Date: Mon Dec 07 1998 - 09:55:26 EST

On Mon, 7 Dec 1998, Otto Stolz wrote:

> In order to process data in various encodings, such as ISO 8859-1, UTF-8,
> and Unicode (UTF-16), a programm has to know about the encoding of the
> actual data. Hence, I cannot understand how a program, such as Vi, could
> work with a locale that does not cover the encoding.

No, it doesn't have to know about the encoding; the encoding is
part of the locale which is external to the program. POSIX
specifies where the en/decoding takes place, but not what the
encoding is.

For example, your program calls fgetwc() to read a character from
a file, the setting of LC_CTYPE tells fgetwc() what algorithm to
use for mapping the imput into the wchar_t (well, wint_t in this
case) datatype. This should work for any single or multi-byte
encoding supported by the locale library of the OS.


This archive was generated by hypermail 2.1.2 : Tue Jul 10 2001 - 17:20:43 EDT