gettext: Charset conversion
1
1 11.2.4 How to specify the output character set ‘gettext’ uses
1 -------------------------------------------------------------
1
1 ‘gettext’ not only looks up a translation in a message catalog. It
1 also converts the translation on the fly to the desired output character
1 set. This is useful if the user is working in a different character set
1 than the translator who created the message catalog, because it avoids
1 distributing variants of message catalogs which differ only in the
1 character set.
1
1 The output character set is, by default, the value of ‘nl_langinfo
1 (CODESET)’, which depends on the ‘LC_CTYPE’ part of the current locale.
1 But programs which store strings in a locale independent way (e.g.
1 UTF-8) can request that ‘gettext’ and related functions return the
1 translations in that encoding, by use of the ‘bind_textdomain_codeset’
1 function.
1
1 Note that the MSGID argument to ‘gettext’ is not subject to character
1 set conversion. Also, when ‘gettext’ does not find a translation for
1 MSGID, it returns MSGID unchanged – independently of the current output
1 character set. It is therefore recommended that all MSGIDs be US-ASCII
1 strings.
1
1 -- Function: char * bind_textdomain_codeset (const char *DOMAINNAME,
1 const char *CODESET)
1 The ‘bind_textdomain_codeset’ function can be used to specify the
1 output character set for message catalogs for domain DOMAINNAME.
1 The CODESET argument must be a valid codeset name which can be used
1 for the ‘iconv_open’ function, or a null pointer.
1
1 If the CODESET parameter is the null pointer,
1 ‘bind_textdomain_codeset’ returns the currently selected codeset
1 for the domain with the name DOMAINNAME. It returns ‘NULL’ if no
1 codeset has yet been selected.
1
1 The ‘bind_textdomain_codeset’ function can be used several times.
1 If used multiple times with the same DOMAINNAME argument, the later
1 call overrides the settings made by the earlier one.
1
1 The ‘bind_textdomain_codeset’ function returns a pointer to a
1 string containing the name of the selected codeset. The string is
1 allocated internally in the function and must not be changed by the
1 user. If the system went out of core during the execution of
1 ‘bind_textdomain_codeset’, the return value is ‘NULL’ and the
1 global variable ERRNO is set accordingly.
1