First off: Although I can understand the relevance of geographic-region detail for LC_TIME, LC_NUMERIC, and most other LC_* vars, I don't quite see how 'en_AU' relates to LC_CTYPE…
Isn't UTF-8 (and other encodings) enough of a definition in themselves (for LC_CTYPE), as and encoding by definiton is consistant?…
Thinking about it as I write, it may be that different regions of the world capitalize their lower-case letters differently… If this is the case, how does iconv
handle this?..
This iconv
point is actually what started me on this line of thought, becaue it doesn't ask for a locale, it only asks for the input encoding format.
My next puzzle is: What do the line-items in the output from locale LC_CTYPE
refer to, and/or where is a good place to get a layout… Perhaps a more relevant question is: By whom, and where, would this info be needed? ..
I'm pretty sure I don't need it… but it all help to fill in the picture of 'scripts' and 'encodings' and 'locales'; which is surprisingly non-trivial as soon as you leave the world of ASCII.
Best Answer
All the locale variables use the same locale name so that you can specify your favorite locale in a single swoop, e.g.
LANG=en_AU.utf8
. As you surmise, the country information is occasionally relevant even inLC_CTYPE
, e.g. the uppercase version ofi
isI
in most languages butİ
in Turkish (tr_TR.utf8
). But don't expect miracles; for example the lowercase-uppercase correspondence is one-to-one, so there's no good uppercase version ofß
inde_DE.iso8859-1
(it should beSS
).You'll have an easier time understanding the output of
locale -k LC_CTYPE
, with-k
to see the keyword names in addition to the values (without-k
, the output format is designed so you can get the value of a specific keyword, e.g.locale ctype-width
). The list of keywords and their meanings is system-dependent, as is the way locale data is stored, and doesn't interest many people, so you may not find much documentation outside the source code of your C library. By far the most useful form of the locale command islocale -a
to list available locale names.For GNU libc (i.e. non-embedded Linux):
/usr/lib/locale/locale-archive
. This file is generated bylocaledef
from data in/usr/share/i18n
and/usr/local/share/i18n
. The format of the locale definition files in/usr/share/i18n/locales
is only documented in the source code, I think./usr/share/i18n/charmaps
is standardized by POSIX:2001. These files (or, in GNU libc, the compiled version in/usr/lib/locale/locale-archive
) are used by the iconv programming and commmand line facility. Encoding conversions also rely on code in/usr/lib/gconv/*.so
. The Gnu libc manual documents how to write your own gconv module, though that section contains the text “This information should be sufficient to write new modules. Anybody doing so should also take a look at the available source code in the GNU C library sources.”./usr/share/locale/*/LC_MESSAGES
. The manual contains documentation for application writers. GNU libc supports both the POSIX interfacecatgets
and the more powerful gettext interface.Written languages are indeed very complicated, even if you don't stray far from English. Are the French and German
ü
the same character (is a “tréma” exactly the same as an “umlaut”, and does it matter that French and German printers typeset the accent at a slightly different height)? What is the uppercase ofi
(it'sİ
in Turkish)? DoesÖ
transliterate toO
if you only have ASCII (in German, it'sOE
)? Where isÄ
sorted in a dictionary (in Swedish, it's afterZ
)? And that's just a few examples with European languages written in the latin alphabet! The Unicode mailing list has a lot of examples and sometimes heated discussions on such topics.