From 1e395daffbcaf787faf771e712b229470fab24a6 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 15 May 2014 00:15:08 -0400 Subject: [PATCH] zwrite: Assume UTF-8 rather than ISO-8859-1 in an ASCII locale It turns out that lots of scripts still run zwrite without setting any locale environment variables. The charset of the default C locale is ANSI_X3.4-1968 (ASCII), so we were sending z_charset = ZCHARSET_ISO_8859_1. But UTF-8 is much more common these days, so this results in a lot of mislabeled zephyrs. Other clients just ignore z_charset (Roost made a good-faith effort to respect it, and gave up after finding that it really has no correlation with the actual charset); but it still caused incorrect display in zwgc. Since UTF-8 is just as good a superset of ASCII as ISO-8859-1 is, we should just assume UTF-8 by default in this case. (We still assume ISO-8859-1 if the locale explicitly specifies that, such as en_US. Almost nobody uses such locales anymore.) Signed-off-by: Anders Kaseorg --- lib/charset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/charset.c b/lib/charset.c index 14aec28f..4d261b9a 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -60,7 +60,7 @@ ZGetCharset(char *charset) if (!strcmp(charset, "NONE") || !strcmp(charset, "UNKNOWN")) retval = ZCHARSET_UNKNOWN; else if (!strcmp(charset, "ANSI_X3.4-1968")) - retval = ZCHARSET_ISO_8859_1; /* A hack. */ + retval = ZCHARSET_UTF_8; /* A hack. */ else if (!strcmp(charset, "ISO-8859-1")) retval = ZCHARSET_ISO_8859_1; else if (!strcmp(charset, "UTF-8"))