DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(gettext.info.gz) Charset conversion

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