zephyr-im / zephyr

An institutional/enterprise-scale distributed real-time messaging and notification system
35 stars 11 forks source link

zwrite: Assume UTF-8 rather than ISO-8859-1 in an ASCII locale #132

Open andersk opened 10 years ago

andersk commented 10 years ago

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.)

davidben commented 10 years ago

LGTM!!