# HG changeset patch # User Paul Eggert # Date 1347817663 25200 # Node ID ece5caebd75e4edfc814c2cc830dcee26bdf3f7b # Parent 80904f7821225b2008bd882ca75c5ba1d4fdefe0 localcharset: work around Mac OS X bug with UTF-8 and MB_CUR_MAX * lib/localcharset.c (locale_charset) [DARWIN7]: Return "ASCII" if the system reports "UTF-8" and MB_CUR_MAX <= 1, as these two values are incompatible. Problem reported by Max Horn. For more discussion, please see . diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2012-09-16 Paul Eggert + localcharset: work around Mac OS X bug with UTF-8 and MB_CUR_MAX + * lib/localcharset.c (locale_charset) [DARWIN7]: + Return "ASCII" if the system reports "UTF-8" and MB_CUR_MAX <= 1, + as these two values are incompatible. Problem reported by Max Horn. + For more discussion, please see + . + doc: document sticky-EOF issue * doc/posix-functions/fgetc.texi (fgetc): * doc/posix-functions/fgets.texi (fgets): diff --git a/lib/localcharset.c b/lib/localcharset.c --- a/lib/localcharset.c +++ b/lib/localcharset.c @@ -542,5 +542,12 @@ if (codeset[0] == '\0') codeset = "ASCII"; +#ifdef DARWIN7 + /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8" + (the default codeset) does not work when MB_CUR_MAX is 1. */ + if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX <= 1) + codeset = "ASCII"; +#endif + return codeset; }