vi(1) and ISO 8859-1

Rocky Hotas rockyhotas at post.com
Thu Apr 4 22:04:47 UTC 2019


> Sent: Thursday, April 04, 2019 at 9:06 PM
> From: "Matthias Apitz" <guru at unixarea.de>
> To: freebsd-questions at freebsd.org
> Subject: Re: vi(1) and ISO 8859-1

[...]

> Are you sure that the file is completely ISO-8859-1 encoded? 

Yes:

> What does
> file(1) says about

$ file myfile
myfile: ISO-8859 text

> and what happens if you run it through iconv(1)
> translating from ISO-8859-1 to UTF-8 into /dev/null, will iconv(1) do it
> or complain?

$ iconv -f ISO-8859-1 -t UTF-8 < myfile > /dev/null

It completes successfully, exit status is 0. You can easily create such a
file and reproduce this: just open vi(1), set the encoding with
`:se fe=iso-8859-1', and just type a letter with an accent, like:

hello
ì

If you save it and reopen it with vi(1), it will use UTF-8 by default and it
won't be able to read the line with `ì', unless you again use
`:se fe=iso-8859-1'.

The correctness (and integrity) of the ISO 8859-1 encoding is also shown by
hexdump:

$ hexdump -C myfile
00000000  68 65 6c 6c 6f 0a ec 0a                           |hello...|
00000008

Where `ec' is `ì' in ISO 8859-1.

Rocky

> 
> 	matthias
> -- 
> Matthias Apitz, ✉ guru at unixarea.de, http://www.unixarea.de/ +49-176-38902045
> Public GnuPG key: http://www.unixarea.de/key.pub
> 70 years of NATO - 70 years of wars (Jugoslavia, Afghanistan, Syria, ...) and 70 years
> of war preparation against Russia.  -- PEACE instead of NATO !


More information about the freebsd-questions mailing list