|
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>setlocale (The Red Hat newlib C Library)</title>
-
- <meta name="description" content="setlocale (The Red Hat newlib C Library)">
- <meta name="keywords" content="setlocale (The Red Hat newlib C Library)">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="makeinfo">
- <link href="index.html#Top" rel="start" title="Top">
- <link href="Document-Index.html#Document-Index" rel="index" title="Document Index">
- <link href="Document-Index.html#SEC_Contents" rel="contents" title="Table of Contents">
- <link href="Locale.html#Locale" rel="up" title="Locale">
- <link href="Reentrancy.html#Reentrancy" rel="next" title="Reentrancy">
- <link href="Locale.html#Locale" rel="prev" title="Locale">
- <style type="text/css">
- <!--
- a.summary-letter {text-decoration: none}
- blockquote.indentedblock {margin-right: 0em}
- blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
- blockquote.smallquotation {font-size: smaller}
- div.display {margin-left: 3.2em}
- div.example {margin-left: 3.2em}
- div.lisp {margin-left: 3.2em}
- div.smalldisplay {margin-left: 3.2em}
- div.smallexample {margin-left: 3.2em}
- div.smalllisp {margin-left: 3.2em}
- kbd {font-style: oblique}
- pre.display {font-family: inherit}
- pre.format {font-family: inherit}
- pre.menu-comment {font-family: serif}
- pre.menu-preformatted {font-family: serif}
- pre.smalldisplay {font-family: inherit; font-size: smaller}
- pre.smallexample {font-size: smaller}
- pre.smallformat {font-family: inherit; font-size: smaller}
- pre.smalllisp {font-size: smaller}
- span.nolinebreak {white-space: nowrap}
- span.roman {font-family: initial; font-weight: normal}
- span.sansserif {font-family: sans-serif; font-weight: normal}
- ul.no-bullet {list-style: none}
- -->
- </style>
-
-
- </head>
-
- <body lang="en">
- <a name="setlocale"></a>
- <div class="header">
- <p>
- Up: <a href="Locale.html#Locale" accesskey="u" rel="up">Locale</a> [<a href="Document-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Document-Index.html#Document-Index" title="Index" rel="index">Index</a>]</p>
- </div>
- <hr>
- <a name="setlocale_002c-localeconv_002d_002d_002dselect-or-query-locale"></a>
- <h3 class="section">9.1 <code>setlocale</code>, <code>localeconv</code>—select or query locale</h3>
- <a name="index-setlocale"></a>
- <a name="index-localeconv"></a>
- <a name="index-_005fsetlocale_005fr"></a>
- <a name="index-_005flocaleconv_005fr"></a>
- <p><strong>Synopsis</strong>
- </p><div class="example">
- <pre class="example">#include <locale.h>
- char *setlocale(int <var>category</var>, const char *<var>locale</var>);
- lconv *localeconv(void);
-
- char *_setlocale_r(void *<var>reent</var>,
- int <var>category</var>, const char *<var>locale</var>);
- lconv *_localeconv_r(void *<var>reent</var>);
-
- </pre></div>
- <p><strong>Description</strong><br>
- <code>setlocale</code> is the facility defined by ANSI C to condition the
- execution environment for international collating and formatting
- information; <code>localeconv</code> reports on the settings of the current
- locale.
- </p>
- <p>This is a minimal implementation, supporting only the required <code>"POSIX"</code>
- and <code>"C"</code> values for <var>locale</var>; strings representing other locales are not
- honored unless _MB_CAPABLE is defined.
- </p>
- <p>If _MB_CAPABLE is defined, POSIX locale strings are allowed, following
- the form
- </p>
- <p>language[_TERRITORY][.charset][@modifier]
- </p>
- <p><code>"language"</code> is a two character string per ISO 639, or, if not available
- for a given language, a three character string per ISO 639-3.
- <code>"TERRITORY"</code> is a country code per ISO 3166. For <code>"charset"</code> and
- <code>"modifier"</code> see below.
- </p>
- <p>Additionally to the POSIX specifier, the following extension is supported
- for backward compatibility with older implementations using newlib:
- <code>"C-charset"</code>.
- Instead of <code>"C-"</code>, you can also specify <code>"C."</code>. Both variations allow
- to specify language neutral locales while using other charsets than ASCII,
- for instance <code>"C.UTF-8"</code>, which keeps all settings as in the C locale,
- but uses the UTF-8 charset.
- </p>
- <p>The following charsets are recognized:
- <code>"UTF-8"</code>, <code>"JIS"</code>, <code>"EUCJP"</code>, <code>"SJIS"</code>, <code>"KOI8-R"</code>, <code>"KOI8-U"</code>,
- <code>"GEORGIAN-PS"</code>, <code>"PT154"</code>, <code>"TIS-620"</code>, <code>"ISO-8859-x"</code> with
- 1 <= x <= 16, or <code>"CPxxx"</code> with xxx in [437, 720, 737, 775, 850, 852, 855,
- 857, 858, 862, 866, 874, 932, 1125, 1250, 1251, 1252, 1253, 1254, 1255, 1256,
- 1257, 1258].
- </p>
- <p>Charsets are case insensitive. For instance, <code>"EUCJP"</code> and <code>"eucJP"</code>
- are equivalent. Charset names with dashes can also be written without
- dashes, as in <code>"UTF8"</code>, <code>"iso88591"</code> or <code>"koi8r"</code>. <code>"EUCJP"</code> and
- <code>"EUCKR"</code> are also recognized with dash, <code>"EUC-JP"</code> and <code>"EUC-KR"</code>.
- </p>
- <p>Full support for all of the above charsets requires that newlib has been
- build with multibyte support and support for all ISO and Windows Codepage.
- Otherwise all singlebyte charsets are simply mapped to ASCII. Right now,
- only newlib for Cygwin is built with full charset support by default.
- Under Cygwin, this implementation additionally supports the charsets
- <code>"GBK"</code>, <code>"GB2312"</code>, <code>"eucCN"</code>, <code>"eucKR"</code>, and <code>"Big5"</code>. Cygwin
- does not support <code>"JIS"</code>.
- </p>
- <p>Cygwin additionally supports locales from the file
- /usr/share/locale/locale.alias.
- </p>
- <p>(<code>""</code> is also accepted; if given, the settings are read from the
- corresponding LC_* environment variables and $LANG according to POSIX rules.)
- </p>
- <p>This implementation also supports the modifiers <code>"cjknarrow"</code> and
- <code>"cjkwide"</code>, which affect how the functions <code>wcwidth</code> and <code>wcswidth</code>
- handle characters from the "CJK Ambiguous Width" category of characters
- described at http://www.unicode.org/reports/tr11/#Ambiguous.
- These characters have a width of 1 for singlebyte charsets and a width of 2
- for multibyte charsets other than UTF-8.
- For UTF-8, their width depends on the language specifier:
- it is 2 for <code>"zh"</code> (Chinese), <code>"ja"</code> (Japanese), and <code>"ko"</code> (Korean),
- and 1 for everything else. Specifying <code>"cjknarrow"</code> or <code>"cjkwide"</code>
- forces a width of 1 or 2, respectively, independent of charset and language.
- </p>
- <p>If you use <code>NULL</code> as the <var>locale</var> argument, <code>setlocale</code> returns a
- pointer to the string representing the current locale. The acceptable
- values for <var>category</var> are defined in ‘<code>locale.h</code>’ as macros
- beginning with <code>"LC_"</code>.
- </p>
- <p><code>localeconv</code> returns a pointer to a structure (also defined in
- ‘<code>locale.h</code>’) describing the locale-specific conventions currently
- in effect.
- </p>
- <p><code>_localeconv_r</code> and <code>_setlocale_r</code> are reentrant versions of
- <code>localeconv</code> and <code>setlocale</code> respectively. The extra argument
- <var>reent</var> is a pointer to a reentrancy structure.
- </p>
- <br>
- <p><strong>Returns</strong><br>
- A successful call to <code>setlocale</code> returns a pointer to a string
- associated with the specified category for the new locale. The string
- returned by <code>setlocale</code> is such that a subsequent call using that
- string will restore that category (or all categories in case of LC_ALL),
- to that state. The application shall not modify the string returned
- which may be overwritten by a subsequent call to <code>setlocale</code>.
- On error, <code>setlocale</code> returns <code>NULL</code>.
- </p>
- <p><code>localeconv</code> returns a pointer to a structure of type <code>lconv</code>,
- which describes the formatting and collating conventions in effect (in
- this implementation, always those of the C locale).
- </p>
- <br>
- <p><strong>Portability</strong><br>
- ANSI C requires <code>setlocale</code>, but the only locale required across all
- implementations is the C locale.
- </p>
- <br>
- <p><strong>Notes</strong><br>
- There is no ISO-8859-12 codepage. It’s also refused by this implementation.
- </p>
- <p>No supporting OS subroutines are required.
- </p>
- <br>
- <hr>
- <div class="header">
- <p>
- Up: <a href="Locale.html#Locale" accesskey="u" rel="up">Locale</a> [<a href="Document-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Document-Index.html#Document-Index" title="Index" rel="index">Index</a>]</p>
- </div>
-
-
-
- </body>
- </html>
|