Why locales
~~~~~~~~~~~

Carob is using locales for two reasons:

1. To encode output (mainly: log messages) according to the user
   preference, just like any well-behaved application. See
   Common.cpp and StringCodecs.cpp

2. As the default option to get an UTF-8 codec to communicate with
   controllers. This is quite standard and portable but may fail
   on some platforms, so it can be disabled and replaced at
   compile-time by CPPFLAGS=-DCAROB_USE_ICONV, at the (low) price
   of a POSIX iconv dependency. See JavaSocket.cpp, CAROB-79 and
   related.


Note: carob is heavily using "wchar_t" and "std::wstring". wchar_t
does NOT need to be a unicode even if this is the most common case.
It may even be locale-dependent. 
<http://www.dinkumware.com/manuals/?manual=compleat&page=multibyte.html#Wide-Character Encodings>
Carob is supposed to be 100% portable to NON-unicode wchar_t systems
(e.g., X0208 or even some 8bit codeset), as long as it can find the
appropriate wchar_t<->UTF-8 codec to communicate with the controller.


Caveats
~~~~~~~

FreeBSD does not support named locales. Probably the same for others
systems using GNU g++ but NOT GNU libc. To investigate.
  <http://gcc.gnu.org/ml/libstdc++/2003-02/msg00350.html>

This seems to be because of concerns from the g++ guys, worried about
the thread safety of non-GNU libc. To investigate.


Diagnose
~~~~~~~~

On most unices and MacOSX > 10.4 use "locale" to check your LANG
settings and run "locale -a" to get the list of all available locales.

Check nl_langinfo() and locale() man pages.


Build/Install a new locale
~~~~~~~~~~~~~~~~~~~~~~~~~~

* "Old" debian-based distros

# dpkg-reconfigure locales


* "New" debian-based distros

The above command does only a rebuild; no re-configuration.
Configuration has now moved to the non-interactive "locale-gen" tool.

# locale-gen <locale from /usr/share/i18n/SUPPORTED>
For instance: # locale-gen fr_FR@euro

For more details check man locale-gen and
http://ubuntuguide.org/wiki/Ubuntu_Edgy#How_to_add_locales_to_Ubuntu_the_command_line_way

* Check the "FAQ Solaris locales"

* The hard way with POSIX' "localedef" (See opengroup.org)

# cd /usr/share/i18n 
# ls locales/ 
   fr_FR ... 
# ls charmaps/ 
   ISO-8859-5.gz ... 
# localedef -i fr_FR -f ISO-8859-15 my.locale 
# locale -a 
   my.locale ... 
# export LANG=my.locale 


A SuSE localedef example:
<http://www.google.com/search?q=SUSE+LINUX+Language+and+Country-Specific+Settings++localedef>



References
----------

"UTF-8 and Unicode FAQ for Unix/Linux" by Markus Kuhn
<http://www.cl.cam.ac.uk/~mgk25/unicode.html>

"Roman Czyborra's charsets resources"
http://czyborra.com/

"Solaris en_US.UTF-8 Locale Support Overview"

"Multibyte Conversions" from Dinkumware
<http://www.dinkumware.com/manuals/?manual=compleat&page=multibyte.html>

GNU C Library Reference Manual ("info glibc")
Chapter Locales and Internationalization 

Enlightning discussion about C++ and locales in the real world
(Windows, Solaris, linux...) A bit outdated but still extremely
informative
<http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/52e04cf87687243d/>

is wchar_t unicode? Status for solaris and FreeBSD
<http://mail.nl.linux.org/linux-utf8/2001-09/msg00076.html>
