Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Jan 2015 22:58:20 +0000
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Baptiste Daroussin <bapt@FreeBSD.org>
Cc:        arch@FreeBSD.org, Jordan Hubbard <jkh@ixsystems.com>, Slawa Olhovchenkov <slw@zxy.spb.ru>
Subject:   Re: [RFC] Set the default locale to en_US.UTF-8
Message-ID:  <24713.1422226700@critter.freebsd.dk>
In-Reply-To: <20150125184608.GO81001@ivaldir.etoilebsd.net>
References:  <20150124143357.GI81001@ivaldir.etoilebsd.net> <20150125143243.GB76051@zxy.spb.ru> <7B1D8345-248B-4C44-9568-079BA29614C2@ixsystems.com> <23506.1422204612@critter.freebsd.dk> <20150125184608.GO81001@ivaldir.etoilebsd.net>

next in thread | previous in thread | raw e-mail | index | archive | help
--------
In message <20150125184608.GO81001@ivaldir.etoilebsd.net>, Baptiste Darous=
sin w
rites:

>> The point about vi(1) is that if you happen to open an ISO-8859 file
>> while in UTF-8 mode, change something on the first line, it will
>> happily and almost imperceptively truncate your file at the first
>> non-UTF byte sequence.
>> =

>> Needless to say, that is *not* the expected behaviour.
>
>That was the case with old vi not with the vi we have in head at least I'=
m =

>not able to truncate files with actual vi

critter phk> env | grep -i utf
XTERM_LOCALE=3Den_US.UTF-8
LC_CTYPE=3Den_US.UTF-8
critter phk> uname -a
FreeBSD critter.freebsd.dk 11.0-CURRENT FreeBSD 11.0-CURRENT #12 r275575: =
Sun Dec  7 11:08:11 UTC 2014     root@critter.freebsd.dk:/freebsd/obj/free=
bsd/svn_src/head/sys/GENERIC  amd64
critter phk> ascii > /tmp/_
critter phk> ls -l /tmp/_
-rw-rw-r--  1 phk  wheel  882 Jan 25 22:54 /tmp/_
critter phk> vi /tmp/_
	(Shows first two lines)
	:w!
	:q
critter phk> ls -l /tmp/_
-rw-rw-r--  1 phk  wheel  98 Jan 25 22:56 /tmp/_

The sourcecode for the ascii programs is:

	#include <stdio.h>

	int
	main(int argc __unused, char **argv __unused)
	{
		int x, y, z;

		for (x =3D 0 ; x < 16; x++)
			printf("%02x ", x * 16);
		printf("\n");
		for (x =3D 0 ; x < 16; x++)
			printf("---");
		printf("\n");
		for (y =3D 0; y < 16; y++) {
			for (x =3D 0 ; x < 16; x++) {
				z =3D y + x * 16;
				if ((x & 7) >=3D 2 && z !=3D 0x7f)
					printf("%c  ", z);
				else
					printf("%02x ", z);
			}
			putchar('\n');
		}
	}

-- =

Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    =

Never attribute to malice what can adequately be explained by incompetence=
.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?24713.1422226700>