[cups.bugs] Re: [MOD] STR #1194: CUPS uses LC_MESSAGES to determine

Mike FABIAN mfabian at suse.de
Fri Jun 10 05:54:34 PDT 2005


[STR New]

(Recycling most of a comment by Markus Kuhn from Bug #41006 on
http://bugzilla.novell.com):

LC_MESSAGES is *not* the variable which determines the charmap of the
current locale. Instead it is determined from the effective value of
LC_CTYPE (I wrote "effective" because LC_CTYPE maybe overridden by
LC_ALL or it may be unset and then it inherits the value from LANG).

See the Open Group's Single Unix Specification, which has since 2001
been identical to the IEEE/ISO POSIX standard, available freely on

  http://www.opengroup.org/onlinepubs/007904975/



under Base Definitions/Environment Variables you can read:

   LC_CTYPE
   This environment variable determines the interpretation of
   sequences of bytes of text data as characters (for example,
   single as opposed to multi-byte characters), the classification
   of characters (for example, alpha, digit, graph), and the
   behavior of character classes.

Further down the same page, this environment variable (like all of LC_*)
inherits a default value from LANG and can be overridden with LC_ALL.
Therefore,
to read LC_CTYPE correctly, you need to use something like

  if (((s = getenv("LC_ALL"))   && *s) ||
      ((s = getenv("LC_CTYPE")) && *s) ||
      ((s = getenv("LANG"))     && *s)) {
    printf("LC_CTYPE = %s\n", s);
  }

The "locale" command line tool does that for example.

The proper way to find out the encoding used is to call the function
nl_langinfo(CODESET), which is also what the command-line "locale
charmap" does, because the name of the used character set is actually
defined in the locale definitions file that is identified by the LANG
or LC_* variable.

Until about two years ago, FreeBSD was the last widely used Unix
variant that still lacked nl_langinfo(), therefore people had to use
workarounds that tried to guess the encoding name from the LC_CTYPE
locale name, which is problematic.  Two such workaround hacks are
linked on

  http://www.cl.cam.ac.uk/~mgk25/unicode.html#activate

Fortunately, in 2003 this practice is no longer needed, because
nl_langinfo() is now a proper universally implemented POSIX API call.

Link: http://www.cups.org/str.php?L1194
Version: 1.1.23





More information about the cups mailing list