vi(1) and ISO 8859-1

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

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


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


> 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:


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 -C myfile
00000000  68 65 6c 6c 6f 0a ec 0a                           |hello...|

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


> 	matthias
> -- 
> Matthias Apitz, ✉ guru at, +49-176-38902045
> Public GnuPG key:
> 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