Atmel CAVR-4 사용자 설명서
![Atmel](https://files.manualsbrain.com/attachments/0369829915bda09f9c2e00fb805a7753579683b5/common/fit/150/50/8d2bf08978ec3e5bc63f4343ac5e91ce8d0e40045619fa520d910d64af8f/brand_logo.png)
CAVR-4
72
Locale
AVR® IAR C/C++ Compiler
Reference Guide
Note: If you use multibyte characters in your C or assembler source code, make sure
that you select the correct locale symbol (the local host locale).
that you select the correct locale symbol (the local host locale).
Building a library without support for locale interface
The locale interface is not included if the configuration symbol
_DLIB_FULL_LOCALE_SUPPORT
is set to 0 (zero). This means that a hardwired locale
is used—by default the standard C locale—but you can choose one of the supported
locale configuration symbols. The
locale configuration symbols. The
setlocale
function is not available and can
therefore not be used for changing locales at runtime.
Building a library with support for locale interface
Support for the locale interface is obtained if the configuration symbol
_DLIB_FULL_LOCALE_SUPPORT
is set to 1. By default, the standard C locale is used,
but you can define as many configuration symbols as required. Because the
setlocale
function will be available in your application, it will be possible to switch locales at
runtime.
runtime.
CHANGING LOCALES AT RUNTIME
The standard library function
setlocale
is used for selecting the appropriate portion
of the application’s locale when the application is running.
The
setlocale
function takes two arguments. The first one is a locale category that is
constructed after the pattern
LC_CATEGORY
. The second argument is a string that
describes the locale. It can either be a string previously returned by
setlocale
, or it
can be a string constructed after the pattern:
lang_REGION
or
lang_REGION.encoding
The
lang
part specifies the language code, and the
REGION
part specifies a region
qualifier, and
encoding
specifies the multibyte encoding that should be used.
The
lang_REGION
part matches the
_LOCALE_USE_LANG
_
REGION
preprocessor
symbols that can be specified in the library configuration file.
Example
This example sets the locale configuration symbols to Swedish to be used in Finland and
UTF8
multibyte encoding:
setlocale (LC_ALL, "sv_FI.Utf8");