[RFC] Set the default locale to en_US.UTF-8

Poul-Henning Kamp phk at phk.freebsd.dk
Sun Jan 25 22:58:25 UTC 2015


--------
In message <20150125184608.GO81001 at ivaldir.etoilebsd.net>, Baptiste Daroussin 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=en_US.UTF-8
LC_CTYPE=en_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 at critter.freebsd.dk:/freebsd/obj/freebsd/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 = 0 ; x < 16; x++)
			printf("%02x ", x * 16);
		printf("\n");
		for (x = 0 ; x < 16; x++)
			printf("---");
		printf("\n");
		for (y = 0; y < 16; y++) {
			for (x = 0 ; x < 16; x++) {
				z = y + x * 16;
				if ((x & 7) >= 2 && z != 0x7f)
					printf("%c  ", z);
				else
					printf("%02x ", z);
			}
			putchar('\n');
		}
	}

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at 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.


More information about the freebsd-arch mailing list