Current Version: '''0.3''' (Updated 2018-10-15) [bll] 2018-8-5 I have written a locale command to work with Tcl. When LC_ALL is set, the locale for LC_NUMERIC is recorded, and LC_NUMERIC is set to "C" so that Tcl numeric parsing still works. The [format] command is locale aware and can be used as in the example below by setting the LC_NUMERIC locale, then resetting LC_NUMERIC back to "C". The [scan] command is not locale aware. On Windows, LC_MESSAGES does not exist. LC_MESSAGES will return LC_ALL. Setting LC_MESSAGES will record the locale setting, but will not change any locale setting. This package can be downloaded from: https://sourceforge.net/projects/tcl-collate/ ====== ### # collate example load [pwd]/locale.so load [pwd]/collate.so locale all set {} set mylist [list A Ä B Z] # try de_DE.UTF-8 and de_CH.UTF-8 lsort -command collate $mylist ### # locale examples # # locale values # locale all/collate/messages/monetary/numeric/time get # locale all/collate/messages/monetary/numeric/time set # locale all/collate/messages/monetary/numeric/time set {} ; # from environment # load [pwd]/locale.so # Initialize all LC_* settings from the environment. # Note that the LC_NUMERIC locale is saved internally, and reset to 'C'. locale all set {} # [locale values] returns some information if you want to use # it directly in your program. # Note that: 'locale all set {}' must be called, locale values -> decimal_point , thousands_sep . grouping 33 currency_symbol € # Getting LC_NUMERIC will return the correct value, though # in reality, it is still set to 'C'. locale numeric get -> de_DE.UTF-8 # The format statement is locale aware. # Setting LC_NUMERIC explicitly works, but you have to remember to # change it back. locale numeric set de_DE.UTF-8 set x [format %.1f 1.5] -> 1,5 locale numeric set C # scan is not locale aware # this regsub handles 90+% of the different locales, I expect regsub , $x . x scan $x %f myvalue # Windows: LC_MESSAGES returns the LC_ALL setting locale messages get -> de_DE.UTF-8 # Windows: setting LC_MESSAGES saves the value, but doesn't change any # locale settings. locale messages set en_US.UTF-8 locale messages get -> en_US.UTF-8 ====== <>Enter Category Here