locale.py 99 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064
  1. """Locale support module.
  2. The module provides low-level access to the C lib's locale APIs and adds high
  3. level number formatting APIs as well as a locale aliasing engine to complement
  4. these.
  5. The aliasing engine includes support for many commonly used locale names and
  6. maps them to values suitable for passing to the C lib's setlocale() function. It
  7. also includes default encodings for all supported locale names.
  8. """
  9. import sys
  10. import encodings
  11. import encodings.aliases
  12. import re
  13. import operator
  14. import functools
  15. # keep a copy of the builtin str type, because 'str' name is overridden
  16. # in globals by a function below
  17. _str = str
  18. try:
  19. _unicode = unicode
  20. except NameError:
  21. # If Python is built without Unicode support, the unicode type
  22. # will not exist. Fake one.
  23. class _unicode(object):
  24. pass
  25. # Try importing the _locale module.
  26. #
  27. # If this fails, fall back on a basic 'C' locale emulation.
  28. # Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before
  29. # trying the import. So __all__ is also fiddled at the end of the file.
  30. __all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
  31. "setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm",
  32. "str", "atof", "atoi", "format", "format_string", "currency",
  33. "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
  34. "LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
  35. try:
  36. from _locale import *
  37. except ImportError:
  38. # Locale emulation
  39. CHAR_MAX = 127
  40. LC_ALL = 6
  41. LC_COLLATE = 3
  42. LC_CTYPE = 0
  43. LC_MESSAGES = 5
  44. LC_MONETARY = 4
  45. LC_NUMERIC = 1
  46. LC_TIME = 2
  47. Error = ValueError
  48. def localeconv():
  49. """ localeconv() -> dict.
  50. Returns numeric and monetary locale-specific parameters.
  51. """
  52. # 'C' locale default values
  53. return {'grouping': [127],
  54. 'currency_symbol': '',
  55. 'n_sign_posn': 127,
  56. 'p_cs_precedes': 127,
  57. 'n_cs_precedes': 127,
  58. 'mon_grouping': [],
  59. 'n_sep_by_space': 127,
  60. 'decimal_point': '.',
  61. 'negative_sign': '',
  62. 'positive_sign': '',
  63. 'p_sep_by_space': 127,
  64. 'int_curr_symbol': '',
  65. 'p_sign_posn': 127,
  66. 'thousands_sep': '',
  67. 'mon_thousands_sep': '',
  68. 'frac_digits': 127,
  69. 'mon_decimal_point': '',
  70. 'int_frac_digits': 127}
  71. def setlocale(category, value=None):
  72. """ setlocale(integer,string=None) -> string.
  73. Activates/queries locale processing.
  74. """
  75. if value not in (None, '', 'C'):
  76. raise Error, '_locale emulation only supports "C" locale'
  77. return 'C'
  78. def strcoll(a,b):
  79. """ strcoll(string,string) -> int.
  80. Compares two strings according to the locale.
  81. """
  82. return cmp(a,b)
  83. def strxfrm(s):
  84. """ strxfrm(string) -> string.
  85. Returns a string that behaves for cmp locale-aware.
  86. """
  87. return s
  88. _localeconv = localeconv
  89. # With this dict, you can override some items of localeconv's return value.
  90. # This is useful for testing purposes.
  91. _override_localeconv = {}
  92. @functools.wraps(_localeconv)
  93. def localeconv():
  94. d = _localeconv()
  95. if _override_localeconv:
  96. d.update(_override_localeconv)
  97. return d
  98. ### Number formatting APIs
  99. # Author: Martin von Loewis
  100. # improved by Georg Brandl
  101. # Iterate over grouping intervals
  102. def _grouping_intervals(grouping):
  103. last_interval = None
  104. for interval in grouping:
  105. # if grouping is -1, we are done
  106. if interval == CHAR_MAX:
  107. return
  108. # 0: re-use last group ad infinitum
  109. if interval == 0:
  110. if last_interval is None:
  111. raise ValueError("invalid grouping")
  112. while True:
  113. yield last_interval
  114. yield interval
  115. last_interval = interval
  116. #perform the grouping from right to left
  117. def _group(s, monetary=False):
  118. conv = localeconv()
  119. thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
  120. grouping = conv[monetary and 'mon_grouping' or 'grouping']
  121. if not grouping:
  122. return (s, 0)
  123. if s[-1] == ' ':
  124. stripped = s.rstrip()
  125. right_spaces = s[len(stripped):]
  126. s = stripped
  127. else:
  128. right_spaces = ''
  129. left_spaces = ''
  130. groups = []
  131. for interval in _grouping_intervals(grouping):
  132. if not s or s[-1] not in "0123456789":
  133. # only non-digit characters remain (sign, spaces)
  134. left_spaces = s
  135. s = ''
  136. break
  137. groups.append(s[-interval:])
  138. s = s[:-interval]
  139. if s:
  140. groups.append(s)
  141. groups.reverse()
  142. return (
  143. left_spaces + thousands_sep.join(groups) + right_spaces,
  144. len(thousands_sep) * (len(groups) - 1)
  145. )
  146. # Strip a given amount of excess padding from the given string
  147. def _strip_padding(s, amount):
  148. lpos = 0
  149. while amount and s[lpos] == ' ':
  150. lpos += 1
  151. amount -= 1
  152. rpos = len(s) - 1
  153. while amount and s[rpos] == ' ':
  154. rpos -= 1
  155. amount -= 1
  156. return s[lpos:rpos+1]
  157. _percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?'
  158. r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')
  159. def format(percent, value, grouping=False, monetary=False, *additional):
  160. """Returns the locale-aware substitution of a %? specifier
  161. (percent).
  162. additional is for format strings which contain one or more
  163. '*' modifiers."""
  164. # this is only for one-percent-specifier strings and this should be checked
  165. match = _percent_re.match(percent)
  166. if not match or len(match.group())!= len(percent):
  167. raise ValueError(("format() must be given exactly one %%char "
  168. "format specifier, %s not valid") % repr(percent))
  169. return _format(percent, value, grouping, monetary, *additional)
  170. def _format(percent, value, grouping=False, monetary=False, *additional):
  171. if additional:
  172. formatted = percent % ((value,) + additional)
  173. else:
  174. formatted = percent % value
  175. # floats and decimal ints need special action!
  176. if percent[-1] in 'eEfFgG':
  177. seps = 0
  178. parts = formatted.split('.')
  179. if grouping:
  180. parts[0], seps = _group(parts[0], monetary=monetary)
  181. decimal_point = localeconv()[monetary and 'mon_decimal_point'
  182. or 'decimal_point']
  183. formatted = decimal_point.join(parts)
  184. if seps:
  185. formatted = _strip_padding(formatted, seps)
  186. elif percent[-1] in 'diu':
  187. seps = 0
  188. if grouping:
  189. formatted, seps = _group(formatted, monetary=monetary)
  190. if seps:
  191. formatted = _strip_padding(formatted, seps)
  192. return formatted
  193. def format_string(f, val, grouping=False):
  194. """Formats a string in the same way that the % formatting would use,
  195. but takes the current locale into account.
  196. Grouping is applied if the third parameter is true."""
  197. percents = list(_percent_re.finditer(f))
  198. new_f = _percent_re.sub('%s', f)
  199. if operator.isMappingType(val):
  200. new_val = []
  201. for perc in percents:
  202. if perc.group()[-1]=='%':
  203. new_val.append('%')
  204. else:
  205. new_val.append(format(perc.group(), val, grouping))
  206. else:
  207. if not isinstance(val, tuple):
  208. val = (val,)
  209. new_val = []
  210. i = 0
  211. for perc in percents:
  212. if perc.group()[-1]=='%':
  213. new_val.append('%')
  214. else:
  215. starcount = perc.group('modifiers').count('*')
  216. new_val.append(_format(perc.group(),
  217. val[i],
  218. grouping,
  219. False,
  220. *val[i+1:i+1+starcount]))
  221. i += (1 + starcount)
  222. val = tuple(new_val)
  223. return new_f % val
  224. def currency(val, symbol=True, grouping=False, international=False):
  225. """Formats val according to the currency settings
  226. in the current locale."""
  227. conv = localeconv()
  228. # check for illegal values
  229. digits = conv[international and 'int_frac_digits' or 'frac_digits']
  230. if digits == 127:
  231. raise ValueError("Currency formatting is not possible using "
  232. "the 'C' locale.")
  233. s = format('%%.%if' % digits, abs(val), grouping, monetary=True)
  234. # '<' and '>' are markers if the sign must be inserted between symbol and value
  235. s = '<' + s + '>'
  236. if symbol:
  237. smb = conv[international and 'int_curr_symbol' or 'currency_symbol']
  238. precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
  239. separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
  240. if precedes:
  241. s = smb + (separated and ' ' or '') + s
  242. else:
  243. s = s + (separated and ' ' or '') + smb
  244. sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
  245. sign = conv[val<0 and 'negative_sign' or 'positive_sign']
  246. if sign_pos == 0:
  247. s = '(' + s + ')'
  248. elif sign_pos == 1:
  249. s = sign + s
  250. elif sign_pos == 2:
  251. s = s + sign
  252. elif sign_pos == 3:
  253. s = s.replace('<', sign)
  254. elif sign_pos == 4:
  255. s = s.replace('>', sign)
  256. else:
  257. # the default if nothing specified;
  258. # this should be the most fitting sign position
  259. s = sign + s
  260. return s.replace('<', '').replace('>', '')
  261. def str(val):
  262. """Convert float to string, taking the locale into account."""
  263. return format("%.12g", val)
  264. def atof(string, func=float):
  265. "Parses a string as a float according to the locale settings."
  266. #First, get rid of the grouping
  267. ts = localeconv()['thousands_sep']
  268. if ts:
  269. string = string.replace(ts, '')
  270. #next, replace the decimal point with a dot
  271. dd = localeconv()['decimal_point']
  272. if dd:
  273. string = string.replace(dd, '.')
  274. #finally, parse the string
  275. return func(string)
  276. def atoi(str):
  277. "Converts a string to an integer according to the locale settings."
  278. return atof(str, int)
  279. def _test():
  280. setlocale(LC_ALL, "")
  281. #do grouping
  282. s1 = format("%d", 123456789,1)
  283. print s1, "is", atoi(s1)
  284. #standard formatting
  285. s1 = str(3.14)
  286. print s1, "is", atof(s1)
  287. ### Locale name aliasing engine
  288. # Author: Marc-Andre Lemburg, mal@lemburg.com
  289. # Various tweaks by Fredrik Lundh <fredrik@pythonware.com>
  290. # store away the low-level version of setlocale (it's
  291. # overridden below)
  292. _setlocale = setlocale
  293. # Avoid relying on the locale-dependent .lower() method
  294. # (see issue #1813).
  295. _ascii_lower_map = ''.join(
  296. chr(x + 32 if x >= ord('A') and x <= ord('Z') else x)
  297. for x in range(256)
  298. )
  299. def _replace_encoding(code, encoding):
  300. if '.' in code:
  301. langname = code[:code.index('.')]
  302. else:
  303. langname = code
  304. # Convert the encoding to a C lib compatible encoding string
  305. norm_encoding = encodings.normalize_encoding(encoding)
  306. #print('norm encoding: %r' % norm_encoding)
  307. norm_encoding = encodings.aliases.aliases.get(norm_encoding,
  308. norm_encoding)
  309. #print('aliased encoding: %r' % norm_encoding)
  310. encoding = locale_encoding_alias.get(norm_encoding,
  311. norm_encoding)
  312. #print('found encoding %r' % encoding)
  313. return langname + '.' + encoding
  314. def normalize(localename):
  315. """ Returns a normalized locale code for the given locale
  316. name.
  317. The returned locale code is formatted for use with
  318. setlocale().
  319. If normalization fails, the original name is returned
  320. unchanged.
  321. If the given encoding is not known, the function defaults to
  322. the default encoding for the locale code just like setlocale()
  323. does.
  324. """
  325. # Normalize the locale name and extract the encoding and modifier
  326. if isinstance(localename, _unicode):
  327. localename = localename.encode('ascii')
  328. code = localename.translate(_ascii_lower_map)
  329. if ':' in code:
  330. # ':' is sometimes used as encoding delimiter.
  331. code = code.replace(':', '.')
  332. if '@' in code:
  333. code, modifier = code.split('@', 1)
  334. else:
  335. modifier = ''
  336. if '.' in code:
  337. langname, encoding = code.split('.')[:2]
  338. else:
  339. langname = code
  340. encoding = ''
  341. # First lookup: fullname (possibly with encoding and modifier)
  342. lang_enc = langname
  343. if encoding:
  344. norm_encoding = encoding.replace('-', '')
  345. norm_encoding = norm_encoding.replace('_', '')
  346. lang_enc += '.' + norm_encoding
  347. lookup_name = lang_enc
  348. if modifier:
  349. lookup_name += '@' + modifier
  350. code = locale_alias.get(lookup_name, None)
  351. if code is not None:
  352. return code
  353. #print('first lookup failed')
  354. if modifier:
  355. # Second try: fullname without modifier (possibly with encoding)
  356. code = locale_alias.get(lang_enc, None)
  357. if code is not None:
  358. #print('lookup without modifier succeeded')
  359. if '@' not in code:
  360. return code + '@' + modifier
  361. if code.split('@', 1)[1].translate(_ascii_lower_map) == modifier:
  362. return code
  363. #print('second lookup failed')
  364. if encoding:
  365. # Third try: langname (without encoding, possibly with modifier)
  366. lookup_name = langname
  367. if modifier:
  368. lookup_name += '@' + modifier
  369. code = locale_alias.get(lookup_name, None)
  370. if code is not None:
  371. #print('lookup without encoding succeeded')
  372. if '@' not in code:
  373. return _replace_encoding(code, encoding)
  374. code, modifier = code.split('@', 1)
  375. return _replace_encoding(code, encoding) + '@' + modifier
  376. if modifier:
  377. # Fourth try: langname (without encoding and modifier)
  378. code = locale_alias.get(langname, None)
  379. if code is not None:
  380. #print('lookup without modifier and encoding succeeded')
  381. if '@' not in code:
  382. return _replace_encoding(code, encoding) + '@' + modifier
  383. code, defmod = code.split('@', 1)
  384. if defmod.translate(_ascii_lower_map) == modifier:
  385. return _replace_encoding(code, encoding) + '@' + defmod
  386. return localename
  387. def _parse_localename(localename):
  388. """ Parses the locale code for localename and returns the
  389. result as tuple (language code, encoding).
  390. The localename is normalized and passed through the locale
  391. alias engine. A ValueError is raised in case the locale name
  392. cannot be parsed.
  393. The language code corresponds to RFC 1766. code and encoding
  394. can be None in case the values cannot be determined or are
  395. unknown to this implementation.
  396. """
  397. code = normalize(localename)
  398. if '@' in code:
  399. # Deal with locale modifiers
  400. code, modifier = code.split('@', 1)
  401. if modifier == 'euro' and '.' not in code:
  402. # Assume Latin-9 for @euro locales. This is bogus,
  403. # since some systems may use other encodings for these
  404. # locales. Also, we ignore other modifiers.
  405. return code, 'iso-8859-15'
  406. if '.' in code:
  407. return tuple(code.split('.')[:2])
  408. elif code == 'C':
  409. return None, None
  410. raise ValueError, 'unknown locale: %s' % localename
  411. def _build_localename(localetuple):
  412. """ Builds a locale code from the given tuple (language code,
  413. encoding).
  414. No aliasing or normalizing takes place.
  415. """
  416. language, encoding = localetuple
  417. if language is None:
  418. language = 'C'
  419. if encoding is None:
  420. return language
  421. else:
  422. return language + '.' + encoding
  423. def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
  424. """ Tries to determine the default locale settings and returns
  425. them as tuple (language code, encoding).
  426. According to POSIX, a program which has not called
  427. setlocale(LC_ALL, "") runs using the portable 'C' locale.
  428. Calling setlocale(LC_ALL, "") lets it use the default locale as
  429. defined by the LANG variable. Since we don't want to interfere
  430. with the current locale setting we thus emulate the behavior
  431. in the way described above.
  432. To maintain compatibility with other platforms, not only the
  433. LANG variable is tested, but a list of variables given as
  434. envvars parameter. The first found to be defined will be
  435. used. envvars defaults to the search path used in GNU gettext;
  436. it must always contain the variable name 'LANG'.
  437. Except for the code 'C', the language code corresponds to RFC
  438. 1766. code and encoding can be None in case the values cannot
  439. be determined.
  440. """
  441. try:
  442. # check if it's supported by the _locale module
  443. import _locale
  444. code, encoding = _locale._getdefaultlocale()
  445. except (ImportError, AttributeError):
  446. pass
  447. else:
  448. # make sure the code/encoding values are valid
  449. if sys.platform == "win32" and code and code[:2] == "0x":
  450. # map windows language identifier to language name
  451. code = windows_locale.get(int(code, 0))
  452. # ...add other platform-specific processing here, if
  453. # necessary...
  454. return code, encoding
  455. # fall back on POSIX behaviour
  456. import os
  457. lookup = os.environ.get
  458. for variable in envvars:
  459. localename = lookup(variable,None)
  460. if localename:
  461. if variable == 'LANGUAGE':
  462. localename = localename.split(':')[0]
  463. break
  464. else:
  465. localename = 'C'
  466. return _parse_localename(localename)
  467. def getlocale(category=LC_CTYPE):
  468. """ Returns the current setting for the given locale category as
  469. tuple (language code, encoding).
  470. category may be one of the LC_* value except LC_ALL. It
  471. defaults to LC_CTYPE.
  472. Except for the code 'C', the language code corresponds to RFC
  473. 1766. code and encoding can be None in case the values cannot
  474. be determined.
  475. """
  476. localename = _setlocale(category)
  477. if category == LC_ALL and ';' in localename:
  478. raise TypeError, 'category LC_ALL is not supported'
  479. return _parse_localename(localename)
  480. def setlocale(category, locale=None):
  481. """ Set the locale for the given category. The locale can be
  482. a string, an iterable of two strings (language code and encoding),
  483. or None.
  484. Iterables are converted to strings using the locale aliasing
  485. engine. Locale strings are passed directly to the C lib.
  486. category may be given as one of the LC_* values.
  487. """
  488. if locale and not isinstance(locale, (_str, _unicode)):
  489. # convert to string
  490. locale = normalize(_build_localename(locale))
  491. return _setlocale(category, locale)
  492. def resetlocale(category=LC_ALL):
  493. """ Sets the locale for category to the default setting.
  494. The default setting is determined by calling
  495. getdefaultlocale(). category defaults to LC_ALL.
  496. """
  497. _setlocale(category, _build_localename(getdefaultlocale()))
  498. if sys.platform.startswith("win"):
  499. # On Win32, this will return the ANSI code page
  500. def getpreferredencoding(do_setlocale = True):
  501. """Return the charset that the user is likely using."""
  502. import _locale
  503. return _locale._getdefaultlocale()[1]
  504. else:
  505. # On Unix, if CODESET is available, use that.
  506. try:
  507. CODESET
  508. except NameError:
  509. # Fall back to parsing environment variables :-(
  510. def getpreferredencoding(do_setlocale = True):
  511. """Return the charset that the user is likely using,
  512. by looking at environment variables."""
  513. return getdefaultlocale()[1]
  514. else:
  515. def getpreferredencoding(do_setlocale = True):
  516. """Return the charset that the user is likely using,
  517. according to the system configuration."""
  518. if do_setlocale:
  519. oldloc = setlocale(LC_CTYPE)
  520. try:
  521. setlocale(LC_CTYPE, "")
  522. except Error:
  523. pass
  524. result = nl_langinfo(CODESET)
  525. setlocale(LC_CTYPE, oldloc)
  526. return result
  527. else:
  528. return nl_langinfo(CODESET)
  529. ### Database
  530. #
  531. # The following data was extracted from the locale.alias file which
  532. # comes with X11 and then hand edited removing the explicit encoding
  533. # definitions and adding some more aliases. The file is usually
  534. # available as /usr/lib/X11/locale/locale.alias.
  535. #
  536. #
  537. # The local_encoding_alias table maps lowercase encoding alias names
  538. # to C locale encoding names (case-sensitive). Note that normalize()
  539. # first looks up the encoding in the encodings.aliases dictionary and
  540. # then applies this mapping to find the correct C lib name for the
  541. # encoding.
  542. #
  543. locale_encoding_alias = {
  544. # Mappings for non-standard encoding names used in locale names
  545. '437': 'C',
  546. 'c': 'C',
  547. 'en': 'ISO8859-1',
  548. 'jis': 'JIS7',
  549. 'jis7': 'JIS7',
  550. 'ajec': 'eucJP',
  551. # Mappings from Python codec names to C lib encoding names
  552. 'ascii': 'ISO8859-1',
  553. 'latin_1': 'ISO8859-1',
  554. 'iso8859_1': 'ISO8859-1',
  555. 'iso8859_10': 'ISO8859-10',
  556. 'iso8859_11': 'ISO8859-11',
  557. 'iso8859_13': 'ISO8859-13',
  558. 'iso8859_14': 'ISO8859-14',
  559. 'iso8859_15': 'ISO8859-15',
  560. 'iso8859_16': 'ISO8859-16',
  561. 'iso8859_2': 'ISO8859-2',
  562. 'iso8859_3': 'ISO8859-3',
  563. 'iso8859_4': 'ISO8859-4',
  564. 'iso8859_5': 'ISO8859-5',
  565. 'iso8859_6': 'ISO8859-6',
  566. 'iso8859_7': 'ISO8859-7',
  567. 'iso8859_8': 'ISO8859-8',
  568. 'iso8859_9': 'ISO8859-9',
  569. 'iso2022_jp': 'JIS7',
  570. 'shift_jis': 'SJIS',
  571. 'tactis': 'TACTIS',
  572. 'euc_jp': 'eucJP',
  573. 'euc_kr': 'eucKR',
  574. 'utf_8': 'UTF-8',
  575. 'koi8_r': 'KOI8-R',
  576. 'koi8_u': 'KOI8-U',
  577. # XXX This list is still incomplete. If you know more
  578. # mappings, please file a bug report. Thanks.
  579. }
  580. #
  581. # The locale_alias table maps lowercase alias names to C locale names
  582. # (case-sensitive). Encodings are always separated from the locale
  583. # name using a dot ('.'); they should only be given in case the
  584. # language name is needed to interpret the given encoding alias
  585. # correctly (CJK codes often have this need).
  586. #
  587. # Note that the normalize() function which uses this tables
  588. # removes '_' and '-' characters from the encoding part of the
  589. # locale name before doing the lookup. This saves a lot of
  590. # space in the table.
  591. #
  592. # MAL 2004-12-10:
  593. # Updated alias mapping to most recent locale.alias file
  594. # from X.org distribution using makelocalealias.py.
  595. #
  596. # These are the differences compared to the old mapping (Python 2.4
  597. # and older):
  598. #
  599. # updated 'bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
  600. # updated 'bg_bg' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
  601. # updated 'bulgarian' -> 'bg_BG.ISO8859-5' to 'bg_BG.CP1251'
  602. # updated 'cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
  603. # updated 'cz_cz' -> 'cz_CZ.ISO8859-2' to 'cs_CZ.ISO8859-2'
  604. # updated 'czech' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
  605. # updated 'dutch' -> 'nl_BE.ISO8859-1' to 'nl_NL.ISO8859-1'
  606. # updated 'et' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
  607. # updated 'et_ee' -> 'et_EE.ISO8859-4' to 'et_EE.ISO8859-15'
  608. # updated 'fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
  609. # updated 'fi_fi' -> 'fi_FI.ISO8859-1' to 'fi_FI.ISO8859-15'
  610. # updated 'iw' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
  611. # updated 'iw_il' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
  612. # updated 'japanese' -> 'ja_JP.SJIS' to 'ja_JP.eucJP'
  613. # updated 'lt' -> 'lt_LT.ISO8859-4' to 'lt_LT.ISO8859-13'
  614. # updated 'lv' -> 'lv_LV.ISO8859-4' to 'lv_LV.ISO8859-13'
  615. # updated 'sl' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
  616. # updated 'slovene' -> 'sl_CS.ISO8859-2' to 'sl_SI.ISO8859-2'
  617. # updated 'th_th' -> 'th_TH.TACTIS' to 'th_TH.ISO8859-11'
  618. # updated 'zh_cn' -> 'zh_CN.eucCN' to 'zh_CN.gb2312'
  619. # updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
  620. # updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
  621. #
  622. # MAL 2008-05-30:
  623. # Updated alias mapping to most recent locale.alias file
  624. # from X.org distribution using makelocalealias.py.
  625. #
  626. # These are the differences compared to the old mapping (Python 2.5
  627. # and older):
  628. #
  629. # updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
  630. # updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
  631. # updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
  632. # updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
  633. # updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
  634. # updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
  635. # updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  636. # updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  637. # updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  638. # updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  639. # updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
  640. # updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  641. # updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
  642. # updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
  643. # updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  644. # updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  645. # updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
  646. # updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
  647. # updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
  648. #
  649. # AP 2010-04-12:
  650. # Updated alias mapping to most recent locale.alias file
  651. # from X.org distribution using makelocalealias.py.
  652. #
  653. # These are the differences compared to the old mapping (Python 2.6.5
  654. # and older):
  655. #
  656. # updated 'ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
  657. # updated 'ru_ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
  658. # updated 'serbocroatian' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
  659. # updated 'sh' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
  660. # updated 'sh_yu' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
  661. # updated 'sr' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
  662. # updated 'sr@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
  663. # updated 'sr@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
  664. # updated 'sr_cs.utf8@latn' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8@latin'
  665. # updated 'sr_cs@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
  666. # updated 'sr_yu' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8@latin'
  667. # updated 'sr_yu.utf8@cyrillic' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8'
  668. # updated 'sr_yu@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
  669. #
  670. # SS 2013-12-20:
  671. # Updated alias mapping to most recent locale.alias file
  672. # from X.org distribution using makelocalealias.py.
  673. #
  674. # These are the differences compared to the old mapping (Python 2.7.6
  675. # and older):
  676. #
  677. # updated 'a3' -> 'a3_AZ.KOI8-C' to 'az_AZ.KOI8-C'
  678. # updated 'a3_az' -> 'a3_AZ.KOI8-C' to 'az_AZ.KOI8-C'
  679. # updated 'a3_az.koi8c' -> 'a3_AZ.KOI8-C' to 'az_AZ.KOI8-C'
  680. # updated 'cs_cs.iso88592' -> 'cs_CS.ISO8859-2' to 'cs_CZ.ISO8859-2'
  681. # updated 'hebrew' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
  682. # updated 'hebrew.iso88598' -> 'iw_IL.ISO8859-8' to 'he_IL.ISO8859-8'
  683. # updated 'sd' -> 'sd_IN@devanagari.UTF-8' to 'sd_IN.UTF-8'
  684. # updated 'sr@latn' -> 'sr_RS.UTF-8@latin' to 'sr_CS.UTF-8@latin'
  685. # updated 'sr_cs' -> 'sr_RS.UTF-8' to 'sr_CS.UTF-8'
  686. # updated 'sr_cs.utf8@latn' -> 'sr_RS.UTF-8@latin' to 'sr_CS.UTF-8@latin'
  687. # updated 'sr_cs@latn' -> 'sr_RS.UTF-8@latin' to 'sr_CS.UTF-8@latin'
  688. #
  689. # SS 2014-10-01:
  690. # Updated alias mapping with glibc 2.19 supported locales.
  691. locale_alias = {
  692. 'a3': 'az_AZ.KOI8-C',
  693. 'a3_az': 'az_AZ.KOI8-C',
  694. 'a3_az.koi8c': 'az_AZ.KOI8-C',
  695. 'a3_az.koic': 'az_AZ.KOI8-C',
  696. 'aa_dj': 'aa_DJ.ISO8859-1',
  697. 'aa_er': 'aa_ER.UTF-8',
  698. 'aa_et': 'aa_ET.UTF-8',
  699. 'af': 'af_ZA.ISO8859-1',
  700. 'af_za': 'af_ZA.ISO8859-1',
  701. 'af_za.iso88591': 'af_ZA.ISO8859-1',
  702. 'am': 'am_ET.UTF-8',
  703. 'am_et': 'am_ET.UTF-8',
  704. 'american': 'en_US.ISO8859-1',
  705. 'american.iso88591': 'en_US.ISO8859-1',
  706. 'an_es': 'an_ES.ISO8859-15',
  707. 'ar': 'ar_AA.ISO8859-6',
  708. 'ar_aa': 'ar_AA.ISO8859-6',
  709. 'ar_aa.iso88596': 'ar_AA.ISO8859-6',
  710. 'ar_ae': 'ar_AE.ISO8859-6',
  711. 'ar_ae.iso88596': 'ar_AE.ISO8859-6',
  712. 'ar_bh': 'ar_BH.ISO8859-6',
  713. 'ar_bh.iso88596': 'ar_BH.ISO8859-6',
  714. 'ar_dz': 'ar_DZ.ISO8859-6',
  715. 'ar_dz.iso88596': 'ar_DZ.ISO8859-6',
  716. 'ar_eg': 'ar_EG.ISO8859-6',
  717. 'ar_eg.iso88596': 'ar_EG.ISO8859-6',
  718. 'ar_in': 'ar_IN.UTF-8',
  719. 'ar_iq': 'ar_IQ.ISO8859-6',
  720. 'ar_iq.iso88596': 'ar_IQ.ISO8859-6',
  721. 'ar_jo': 'ar_JO.ISO8859-6',
  722. 'ar_jo.iso88596': 'ar_JO.ISO8859-6',
  723. 'ar_kw': 'ar_KW.ISO8859-6',
  724. 'ar_kw.iso88596': 'ar_KW.ISO8859-6',
  725. 'ar_lb': 'ar_LB.ISO8859-6',
  726. 'ar_lb.iso88596': 'ar_LB.ISO8859-6',
  727. 'ar_ly': 'ar_LY.ISO8859-6',
  728. 'ar_ly.iso88596': 'ar_LY.ISO8859-6',
  729. 'ar_ma': 'ar_MA.ISO8859-6',
  730. 'ar_ma.iso88596': 'ar_MA.ISO8859-6',
  731. 'ar_om': 'ar_OM.ISO8859-6',
  732. 'ar_om.iso88596': 'ar_OM.ISO8859-6',
  733. 'ar_qa': 'ar_QA.ISO8859-6',
  734. 'ar_qa.iso88596': 'ar_QA.ISO8859-6',
  735. 'ar_sa': 'ar_SA.ISO8859-6',
  736. 'ar_sa.iso88596': 'ar_SA.ISO8859-6',
  737. 'ar_sd': 'ar_SD.ISO8859-6',
  738. 'ar_sd.iso88596': 'ar_SD.ISO8859-6',
  739. 'ar_sy': 'ar_SY.ISO8859-6',
  740. 'ar_sy.iso88596': 'ar_SY.ISO8859-6',
  741. 'ar_tn': 'ar_TN.ISO8859-6',
  742. 'ar_tn.iso88596': 'ar_TN.ISO8859-6',
  743. 'ar_ye': 'ar_YE.ISO8859-6',
  744. 'ar_ye.iso88596': 'ar_YE.ISO8859-6',
  745. 'arabic': 'ar_AA.ISO8859-6',
  746. 'arabic.iso88596': 'ar_AA.ISO8859-6',
  747. 'as': 'as_IN.UTF-8',
  748. 'as_in': 'as_IN.UTF-8',
  749. 'ast_es': 'ast_ES.ISO8859-15',
  750. 'ayc_pe': 'ayc_PE.UTF-8',
  751. 'az': 'az_AZ.ISO8859-9E',
  752. 'az_az': 'az_AZ.ISO8859-9E',
  753. 'az_az.iso88599e': 'az_AZ.ISO8859-9E',
  754. 'be': 'be_BY.CP1251',
  755. 'be@latin': 'be_BY.UTF-8@latin',
  756. 'be_bg.utf8': 'bg_BG.UTF-8',
  757. 'be_by': 'be_BY.CP1251',
  758. 'be_by.cp1251': 'be_BY.CP1251',
  759. 'be_by.microsoftcp1251': 'be_BY.CP1251',
  760. 'be_by.utf8@latin': 'be_BY.UTF-8@latin',
  761. 'be_by@latin': 'be_BY.UTF-8@latin',
  762. 'bem_zm': 'bem_ZM.UTF-8',
  763. 'ber_dz': 'ber_DZ.UTF-8',
  764. 'ber_ma': 'ber_MA.UTF-8',
  765. 'bg': 'bg_BG.CP1251',
  766. 'bg_bg': 'bg_BG.CP1251',
  767. 'bg_bg.cp1251': 'bg_BG.CP1251',
  768. 'bg_bg.iso88595': 'bg_BG.ISO8859-5',
  769. 'bg_bg.koi8r': 'bg_BG.KOI8-R',
  770. 'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
  771. 'bho_in': 'bho_IN.UTF-8',
  772. 'bn_bd': 'bn_BD.UTF-8',
  773. 'bn_in': 'bn_IN.UTF-8',
  774. 'bo_cn': 'bo_CN.UTF-8',
  775. 'bo_in': 'bo_IN.UTF-8',
  776. 'bokmal': 'nb_NO.ISO8859-1',
  777. 'bokm\xe5l': 'nb_NO.ISO8859-1',
  778. 'br': 'br_FR.ISO8859-1',
  779. 'br_fr': 'br_FR.ISO8859-1',
  780. 'br_fr.iso88591': 'br_FR.ISO8859-1',
  781. 'br_fr.iso885914': 'br_FR.ISO8859-14',
  782. 'br_fr.iso885915': 'br_FR.ISO8859-15',
  783. 'br_fr.iso885915@euro': 'br_FR.ISO8859-15',
  784. 'br_fr.utf8@euro': 'br_FR.UTF-8',
  785. 'br_fr@euro': 'br_FR.ISO8859-15',
  786. 'brx_in': 'brx_IN.UTF-8',
  787. 'bs': 'bs_BA.ISO8859-2',
  788. 'bs_ba': 'bs_BA.ISO8859-2',
  789. 'bs_ba.iso88592': 'bs_BA.ISO8859-2',
  790. 'bulgarian': 'bg_BG.CP1251',
  791. 'byn_er': 'byn_ER.UTF-8',
  792. 'c': 'C',
  793. 'c-french': 'fr_CA.ISO8859-1',
  794. 'c-french.iso88591': 'fr_CA.ISO8859-1',
  795. 'c.ascii': 'C',
  796. 'c.en': 'C',
  797. 'c.iso88591': 'en_US.ISO8859-1',
  798. 'c.utf8': 'en_US.UTF-8',
  799. 'c_c': 'C',
  800. 'c_c.c': 'C',
  801. 'ca': 'ca_ES.ISO8859-1',
  802. 'ca_ad': 'ca_AD.ISO8859-1',
  803. 'ca_ad.iso88591': 'ca_AD.ISO8859-1',
  804. 'ca_ad.iso885915': 'ca_AD.ISO8859-15',
  805. 'ca_ad.iso885915@euro': 'ca_AD.ISO8859-15',
  806. 'ca_ad.utf8@euro': 'ca_AD.UTF-8',
  807. 'ca_ad@euro': 'ca_AD.ISO8859-15',
  808. 'ca_es': 'ca_ES.ISO8859-1',
  809. 'ca_es.iso88591': 'ca_ES.ISO8859-1',
  810. 'ca_es.iso885915': 'ca_ES.ISO8859-15',
  811. 'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
  812. 'ca_es.utf8@euro': 'ca_ES.UTF-8',
  813. 'ca_es@valencia': 'ca_ES.ISO8859-15@valencia',
  814. 'ca_es@euro': 'ca_ES.ISO8859-15',
  815. 'ca_fr': 'ca_FR.ISO8859-1',
  816. 'ca_fr.iso88591': 'ca_FR.ISO8859-1',
  817. 'ca_fr.iso885915': 'ca_FR.ISO8859-15',
  818. 'ca_fr.iso885915@euro': 'ca_FR.ISO8859-15',
  819. 'ca_fr.utf8@euro': 'ca_FR.UTF-8',
  820. 'ca_fr@euro': 'ca_FR.ISO8859-15',
  821. 'ca_it': 'ca_IT.ISO8859-1',
  822. 'ca_it.iso88591': 'ca_IT.ISO8859-1',
  823. 'ca_it.iso885915': 'ca_IT.ISO8859-15',
  824. 'ca_it.iso885915@euro': 'ca_IT.ISO8859-15',
  825. 'ca_it.utf8@euro': 'ca_IT.UTF-8',
  826. 'ca_it@euro': 'ca_IT.ISO8859-15',
  827. 'catalan': 'ca_ES.ISO8859-1',
  828. 'cextend': 'en_US.ISO8859-1',
  829. 'cextend.en': 'en_US.ISO8859-1',
  830. 'chinese-s': 'zh_CN.eucCN',
  831. 'chinese-t': 'zh_TW.eucTW',
  832. 'crh_ua': 'crh_UA.UTF-8',
  833. 'croatian': 'hr_HR.ISO8859-2',
  834. 'cs': 'cs_CZ.ISO8859-2',
  835. 'cs_cs': 'cs_CZ.ISO8859-2',
  836. 'cs_cs.iso88592': 'cs_CZ.ISO8859-2',
  837. 'cs_cz': 'cs_CZ.ISO8859-2',
  838. 'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
  839. 'csb_pl': 'csb_PL.UTF-8',
  840. 'cv_ru': 'cv_RU.UTF-8',
  841. 'cy': 'cy_GB.ISO8859-1',
  842. 'cy_gb': 'cy_GB.ISO8859-1',
  843. 'cy_gb.iso88591': 'cy_GB.ISO8859-1',
  844. 'cy_gb.iso885914': 'cy_GB.ISO8859-14',
  845. 'cy_gb.iso885915': 'cy_GB.ISO8859-15',
  846. 'cy_gb@euro': 'cy_GB.ISO8859-15',
  847. 'cz': 'cs_CZ.ISO8859-2',
  848. 'cz_cz': 'cs_CZ.ISO8859-2',
  849. 'czech': 'cs_CZ.ISO8859-2',
  850. 'da': 'da_DK.ISO8859-1',
  851. 'da.iso885915': 'da_DK.ISO8859-15',
  852. 'da_dk': 'da_DK.ISO8859-1',
  853. 'da_dk.88591': 'da_DK.ISO8859-1',
  854. 'da_dk.885915': 'da_DK.ISO8859-15',
  855. 'da_dk.iso88591': 'da_DK.ISO8859-1',
  856. 'da_dk.iso885915': 'da_DK.ISO8859-15',
  857. 'da_dk@euro': 'da_DK.ISO8859-15',
  858. 'danish': 'da_DK.ISO8859-1',
  859. 'danish.iso88591': 'da_DK.ISO8859-1',
  860. 'dansk': 'da_DK.ISO8859-1',
  861. 'de': 'de_DE.ISO8859-1',
  862. 'de.iso885915': 'de_DE.ISO8859-15',
  863. 'de_at': 'de_AT.ISO8859-1',
  864. 'de_at.iso88591': 'de_AT.ISO8859-1',
  865. 'de_at.iso885915': 'de_AT.ISO8859-15',
  866. 'de_at.iso885915@euro': 'de_AT.ISO8859-15',
  867. 'de_at.utf8@euro': 'de_AT.UTF-8',
  868. 'de_at@euro': 'de_AT.ISO8859-15',
  869. 'de_be': 'de_BE.ISO8859-1',
  870. 'de_be.iso88591': 'de_BE.ISO8859-1',
  871. 'de_be.iso885915': 'de_BE.ISO8859-15',
  872. 'de_be.iso885915@euro': 'de_BE.ISO8859-15',
  873. 'de_be.utf8@euro': 'de_BE.UTF-8',
  874. 'de_be@euro': 'de_BE.ISO8859-15',
  875. 'de_ch': 'de_CH.ISO8859-1',
  876. 'de_ch.iso88591': 'de_CH.ISO8859-1',
  877. 'de_ch.iso885915': 'de_CH.ISO8859-15',
  878. 'de_ch@euro': 'de_CH.ISO8859-15',
  879. 'de_de': 'de_DE.ISO8859-1',
  880. 'de_de.88591': 'de_DE.ISO8859-1',
  881. 'de_de.885915': 'de_DE.ISO8859-15',
  882. 'de_de.885915@euro': 'de_DE.ISO8859-15',
  883. 'de_de.iso88591': 'de_DE.ISO8859-1',
  884. 'de_de.iso885915': 'de_DE.ISO8859-15',
  885. 'de_de.iso885915@euro': 'de_DE.ISO8859-15',
  886. 'de_de.utf8@euro': 'de_DE.UTF-8',
  887. 'de_de@euro': 'de_DE.ISO8859-15',
  888. 'de_li.utf8': 'de_LI.UTF-8',
  889. 'de_lu': 'de_LU.ISO8859-1',
  890. 'de_lu.iso88591': 'de_LU.ISO8859-1',
  891. 'de_lu.iso885915': 'de_LU.ISO8859-15',
  892. 'de_lu.iso885915@euro': 'de_LU.ISO8859-15',
  893. 'de_lu.utf8@euro': 'de_LU.UTF-8',
  894. 'de_lu@euro': 'de_LU.ISO8859-15',
  895. 'deutsch': 'de_DE.ISO8859-1',
  896. 'doi_in': 'doi_IN.UTF-8',
  897. 'dutch': 'nl_NL.ISO8859-1',
  898. 'dutch.iso88591': 'nl_BE.ISO8859-1',
  899. 'dv_mv': 'dv_MV.UTF-8',
  900. 'dz_bt': 'dz_BT.UTF-8',
  901. 'ee': 'ee_EE.ISO8859-4',
  902. 'ee_ee': 'ee_EE.ISO8859-4',
  903. 'ee_ee.iso88594': 'ee_EE.ISO8859-4',
  904. 'eesti': 'et_EE.ISO8859-1',
  905. 'el': 'el_GR.ISO8859-7',
  906. 'el_cy': 'el_CY.ISO8859-7',
  907. 'el_gr': 'el_GR.ISO8859-7',
  908. 'el_gr.iso88597': 'el_GR.ISO8859-7',
  909. 'el_gr@euro': 'el_GR.ISO8859-15',
  910. 'en': 'en_US.ISO8859-1',
  911. 'en.iso88591': 'en_US.ISO8859-1',
  912. 'en_ag': 'en_AG.UTF-8',
  913. 'en_au': 'en_AU.ISO8859-1',
  914. 'en_au.iso88591': 'en_AU.ISO8859-1',
  915. 'en_be': 'en_BE.ISO8859-1',
  916. 'en_be@euro': 'en_BE.ISO8859-15',
  917. 'en_bw': 'en_BW.ISO8859-1',
  918. 'en_bw.iso88591': 'en_BW.ISO8859-1',
  919. 'en_ca': 'en_CA.ISO8859-1',
  920. 'en_ca.iso88591': 'en_CA.ISO8859-1',
  921. 'en_dk': 'en_DK.ISO8859-1',
  922. 'en_dl.utf8': 'en_DL.UTF-8',
  923. 'en_gb': 'en_GB.ISO8859-1',
  924. 'en_gb.88591': 'en_GB.ISO8859-1',
  925. 'en_gb.iso88591': 'en_GB.ISO8859-1',
  926. 'en_gb.iso885915': 'en_GB.ISO8859-15',
  927. 'en_gb@euro': 'en_GB.ISO8859-15',
  928. 'en_hk': 'en_HK.ISO8859-1',
  929. 'en_hk.iso88591': 'en_HK.ISO8859-1',
  930. 'en_ie': 'en_IE.ISO8859-1',
  931. 'en_ie.iso88591': 'en_IE.ISO8859-1',
  932. 'en_ie.iso885915': 'en_IE.ISO8859-15',
  933. 'en_ie.iso885915@euro': 'en_IE.ISO8859-15',
  934. 'en_ie.utf8@euro': 'en_IE.UTF-8',
  935. 'en_ie@euro': 'en_IE.ISO8859-15',
  936. 'en_in': 'en_IN.ISO8859-1',
  937. 'en_ng': 'en_NG.UTF-8',
  938. 'en_nz': 'en_NZ.ISO8859-1',
  939. 'en_nz.iso88591': 'en_NZ.ISO8859-1',
  940. 'en_ph': 'en_PH.ISO8859-1',
  941. 'en_ph.iso88591': 'en_PH.ISO8859-1',
  942. 'en_sg': 'en_SG.ISO8859-1',
  943. 'en_sg.iso88591': 'en_SG.ISO8859-1',
  944. 'en_uk': 'en_GB.ISO8859-1',
  945. 'en_us': 'en_US.ISO8859-1',
  946. 'en_us.88591': 'en_US.ISO8859-1',
  947. 'en_us.885915': 'en_US.ISO8859-15',
  948. 'en_us.iso88591': 'en_US.ISO8859-1',
  949. 'en_us.iso885915': 'en_US.ISO8859-15',
  950. 'en_us.iso885915@euro': 'en_US.ISO8859-15',
  951. 'en_us@euro': 'en_US.ISO8859-15',
  952. 'en_us@euro@euro': 'en_US.ISO8859-15',
  953. 'en_za': 'en_ZA.ISO8859-1',
  954. 'en_za.88591': 'en_ZA.ISO8859-1',
  955. 'en_za.iso88591': 'en_ZA.ISO8859-1',
  956. 'en_za.iso885915': 'en_ZA.ISO8859-15',
  957. 'en_za@euro': 'en_ZA.ISO8859-15',
  958. 'en_zm': 'en_ZM.UTF-8',
  959. 'en_zw': 'en_ZW.ISO8859-1',
  960. 'en_zw.iso88591': 'en_ZW.ISO8859-1',
  961. 'en_zw.utf8': 'en_ZS.UTF-8',
  962. 'eng_gb': 'en_GB.ISO8859-1',
  963. 'eng_gb.8859': 'en_GB.ISO8859-1',
  964. 'english': 'en_EN.ISO8859-1',
  965. 'english.iso88591': 'en_EN.ISO8859-1',
  966. 'english_uk': 'en_GB.ISO8859-1',
  967. 'english_uk.8859': 'en_GB.ISO8859-1',
  968. 'english_united-states': 'en_US.ISO8859-1',
  969. 'english_united-states.437': 'C',
  970. 'english_us': 'en_US.ISO8859-1',
  971. 'english_us.8859': 'en_US.ISO8859-1',
  972. 'english_us.ascii': 'en_US.ISO8859-1',
  973. 'eo': 'eo_XX.ISO8859-3',
  974. 'eo.utf8': 'eo.UTF-8',
  975. 'eo_eo': 'eo_EO.ISO8859-3',
  976. 'eo_eo.iso88593': 'eo_EO.ISO8859-3',
  977. 'eo_us.utf8': 'eo_US.UTF-8',
  978. 'eo_xx': 'eo_XX.ISO8859-3',
  979. 'eo_xx.iso88593': 'eo_XX.ISO8859-3',
  980. 'es': 'es_ES.ISO8859-1',
  981. 'es_ar': 'es_AR.ISO8859-1',
  982. 'es_ar.iso88591': 'es_AR.ISO8859-1',
  983. 'es_bo': 'es_BO.ISO8859-1',
  984. 'es_bo.iso88591': 'es_BO.ISO8859-1',
  985. 'es_cl': 'es_CL.ISO8859-1',
  986. 'es_cl.iso88591': 'es_CL.ISO8859-1',
  987. 'es_co': 'es_CO.ISO8859-1',
  988. 'es_co.iso88591': 'es_CO.ISO8859-1',
  989. 'es_cr': 'es_CR.ISO8859-1',
  990. 'es_cr.iso88591': 'es_CR.ISO8859-1',
  991. 'es_cu': 'es_CU.UTF-8',
  992. 'es_do': 'es_DO.ISO8859-1',
  993. 'es_do.iso88591': 'es_DO.ISO8859-1',
  994. 'es_ec': 'es_EC.ISO8859-1',
  995. 'es_ec.iso88591': 'es_EC.ISO8859-1',
  996. 'es_es': 'es_ES.ISO8859-1',
  997. 'es_es.88591': 'es_ES.ISO8859-1',
  998. 'es_es.iso88591': 'es_ES.ISO8859-1',
  999. 'es_es.iso885915': 'es_ES.ISO8859-15',
  1000. 'es_es.iso885915@euro': 'es_ES.ISO8859-15',
  1001. 'es_es.utf8@euro': 'es_ES.UTF-8',
  1002. 'es_es@euro': 'es_ES.ISO8859-15',
  1003. 'es_gt': 'es_GT.ISO8859-1',
  1004. 'es_gt.iso88591': 'es_GT.ISO8859-1',
  1005. 'es_hn': 'es_HN.ISO8859-1',
  1006. 'es_hn.iso88591': 'es_HN.ISO8859-1',
  1007. 'es_mx': 'es_MX.ISO8859-1',
  1008. 'es_mx.iso88591': 'es_MX.ISO8859-1',
  1009. 'es_ni': 'es_NI.ISO8859-1',
  1010. 'es_ni.iso88591': 'es_NI.ISO8859-1',
  1011. 'es_pa': 'es_PA.ISO8859-1',
  1012. 'es_pa.iso88591': 'es_PA.ISO8859-1',
  1013. 'es_pa.iso885915': 'es_PA.ISO8859-15',
  1014. 'es_pa@euro': 'es_PA.ISO8859-15',
  1015. 'es_pe': 'es_PE.ISO8859-1',
  1016. 'es_pe.iso88591': 'es_PE.ISO8859-1',
  1017. 'es_pe.iso885915': 'es_PE.ISO8859-15',
  1018. 'es_pe@euro': 'es_PE.ISO8859-15',
  1019. 'es_pr': 'es_PR.ISO8859-1',
  1020. 'es_pr.iso88591': 'es_PR.ISO8859-1',
  1021. 'es_py': 'es_PY.ISO8859-1',
  1022. 'es_py.iso88591': 'es_PY.ISO8859-1',
  1023. 'es_py.iso885915': 'es_PY.ISO8859-15',
  1024. 'es_py@euro': 'es_PY.ISO8859-15',
  1025. 'es_sv': 'es_SV.ISO8859-1',
  1026. 'es_sv.iso88591': 'es_SV.ISO8859-1',
  1027. 'es_sv.iso885915': 'es_SV.ISO8859-15',
  1028. 'es_sv@euro': 'es_SV.ISO8859-15',
  1029. 'es_us': 'es_US.ISO8859-1',
  1030. 'es_us.iso88591': 'es_US.ISO8859-1',
  1031. 'es_uy': 'es_UY.ISO8859-1',
  1032. 'es_uy.iso88591': 'es_UY.ISO8859-1',
  1033. 'es_uy.iso885915': 'es_UY.ISO8859-15',
  1034. 'es_uy@euro': 'es_UY.ISO8859-15',
  1035. 'es_ve': 'es_VE.ISO8859-1',
  1036. 'es_ve.iso88591': 'es_VE.ISO8859-1',
  1037. 'es_ve.iso885915': 'es_VE.ISO8859-15',
  1038. 'es_ve@euro': 'es_VE.ISO8859-15',
  1039. 'estonian': 'et_EE.ISO8859-1',
  1040. 'et': 'et_EE.ISO8859-15',
  1041. 'et_ee': 'et_EE.ISO8859-15',
  1042. 'et_ee.iso88591': 'et_EE.ISO8859-1',
  1043. 'et_ee.iso885913': 'et_EE.ISO8859-13',
  1044. 'et_ee.iso885915': 'et_EE.ISO8859-15',
  1045. 'et_ee.iso88594': 'et_EE.ISO8859-4',
  1046. 'et_ee@euro': 'et_EE.ISO8859-15',
  1047. 'eu': 'eu_ES.ISO8859-1',
  1048. 'eu_es': 'eu_ES.ISO8859-1',
  1049. 'eu_es.iso88591': 'eu_ES.ISO8859-1',
  1050. 'eu_es.iso885915': 'eu_ES.ISO8859-15',
  1051. 'eu_es.iso885915@euro': 'eu_ES.ISO8859-15',
  1052. 'eu_es.utf8@euro': 'eu_ES.UTF-8',
  1053. 'eu_es@euro': 'eu_ES.ISO8859-15',
  1054. 'eu_fr': 'eu_FR.ISO8859-1',
  1055. 'fa': 'fa_IR.UTF-8',
  1056. 'fa_ir': 'fa_IR.UTF-8',
  1057. 'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
  1058. 'ff_sn': 'ff_SN.UTF-8',
  1059. 'fi': 'fi_FI.ISO8859-15',
  1060. 'fi.iso885915': 'fi_FI.ISO8859-15',
  1061. 'fi_fi': 'fi_FI.ISO8859-15',
  1062. 'fi_fi.88591': 'fi_FI.ISO8859-1',
  1063. 'fi_fi.iso88591': 'fi_FI.ISO8859-1',
  1064. 'fi_fi.iso885915': 'fi_FI.ISO8859-15',
  1065. 'fi_fi.iso885915@euro': 'fi_FI.ISO8859-15',
  1066. 'fi_fi.utf8@euro': 'fi_FI.UTF-8',
  1067. 'fi_fi@euro': 'fi_FI.ISO8859-15',
  1068. 'fil_ph': 'fil_PH.UTF-8',
  1069. 'finnish': 'fi_FI.ISO8859-1',
  1070. 'finnish.iso88591': 'fi_FI.ISO8859-1',
  1071. 'fo': 'fo_FO.ISO8859-1',
  1072. 'fo_fo': 'fo_FO.ISO8859-1',
  1073. 'fo_fo.iso88591': 'fo_FO.ISO8859-1',
  1074. 'fo_fo.iso885915': 'fo_FO.ISO8859-15',
  1075. 'fo_fo@euro': 'fo_FO.ISO8859-15',
  1076. 'fr': 'fr_FR.ISO8859-1',
  1077. 'fr.iso885915': 'fr_FR.ISO8859-15',
  1078. 'fr_be': 'fr_BE.ISO8859-1',
  1079. 'fr_be.88591': 'fr_BE.ISO8859-1',
  1080. 'fr_be.iso88591': 'fr_BE.ISO8859-1',
  1081. 'fr_be.iso885915': 'fr_BE.ISO8859-15',
  1082. 'fr_be.iso885915@euro': 'fr_BE.ISO8859-15',
  1083. 'fr_be.utf8@euro': 'fr_BE.UTF-8',
  1084. 'fr_be@euro': 'fr_BE.ISO8859-15',
  1085. 'fr_ca': 'fr_CA.ISO8859-1',
  1086. 'fr_ca.88591': 'fr_CA.ISO8859-1',
  1087. 'fr_ca.iso88591': 'fr_CA.ISO8859-1',
  1088. 'fr_ca.iso885915': 'fr_CA.ISO8859-15',
  1089. 'fr_ca@euro': 'fr_CA.ISO8859-15',
  1090. 'fr_ch': 'fr_CH.ISO8859-1',
  1091. 'fr_ch.88591': 'fr_CH.ISO8859-1',
  1092. 'fr_ch.iso88591': 'fr_CH.ISO8859-1',
  1093. 'fr_ch.iso885915': 'fr_CH.ISO8859-15',
  1094. 'fr_ch@euro': 'fr_CH.ISO8859-15',
  1095. 'fr_fr': 'fr_FR.ISO8859-1',
  1096. 'fr_fr.88591': 'fr_FR.ISO8859-1',
  1097. 'fr_fr.iso88591': 'fr_FR.ISO8859-1',
  1098. 'fr_fr.iso885915': 'fr_FR.ISO8859-15',
  1099. 'fr_fr.iso885915@euro': 'fr_FR.ISO8859-15',
  1100. 'fr_fr.utf8@euro': 'fr_FR.UTF-8',
  1101. 'fr_fr@euro': 'fr_FR.ISO8859-15',
  1102. 'fr_lu': 'fr_LU.ISO8859-1',
  1103. 'fr_lu.88591': 'fr_LU.ISO8859-1',
  1104. 'fr_lu.iso88591': 'fr_LU.ISO8859-1',
  1105. 'fr_lu.iso885915': 'fr_LU.ISO8859-15',
  1106. 'fr_lu.iso885915@euro': 'fr_LU.ISO8859-15',
  1107. 'fr_lu.utf8@euro': 'fr_LU.UTF-8',
  1108. 'fr_lu@euro': 'fr_LU.ISO8859-15',
  1109. 'fran\xe7ais': 'fr_FR.ISO8859-1',
  1110. 'fre_fr': 'fr_FR.ISO8859-1',
  1111. 'fre_fr.8859': 'fr_FR.ISO8859-1',
  1112. 'french': 'fr_FR.ISO8859-1',
  1113. 'french.iso88591': 'fr_CH.ISO8859-1',
  1114. 'french_france': 'fr_FR.ISO8859-1',
  1115. 'french_france.8859': 'fr_FR.ISO8859-1',
  1116. 'fur_it': 'fur_IT.UTF-8',
  1117. 'fy_de': 'fy_DE.UTF-8',
  1118. 'fy_nl': 'fy_NL.UTF-8',
  1119. 'ga': 'ga_IE.ISO8859-1',
  1120. 'ga_ie': 'ga_IE.ISO8859-1',
  1121. 'ga_ie.iso88591': 'ga_IE.ISO8859-1',
  1122. 'ga_ie.iso885914': 'ga_IE.ISO8859-14',
  1123. 'ga_ie.iso885915': 'ga_IE.ISO8859-15',
  1124. 'ga_ie.iso885915@euro': 'ga_IE.ISO8859-15',
  1125. 'ga_ie.utf8@euro': 'ga_IE.UTF-8',
  1126. 'ga_ie@euro': 'ga_IE.ISO8859-15',
  1127. 'galego': 'gl_ES.ISO8859-1',
  1128. 'galician': 'gl_ES.ISO8859-1',
  1129. 'gd': 'gd_GB.ISO8859-1',
  1130. 'gd_gb': 'gd_GB.ISO8859-1',
  1131. 'gd_gb.iso88591': 'gd_GB.ISO8859-1',
  1132. 'gd_gb.iso885914': 'gd_GB.ISO8859-14',
  1133. 'gd_gb.iso885915': 'gd_GB.ISO8859-15',
  1134. 'gd_gb@euro': 'gd_GB.ISO8859-15',
  1135. 'ger_de': 'de_DE.ISO8859-1',
  1136. 'ger_de.8859': 'de_DE.ISO8859-1',
  1137. 'german': 'de_DE.ISO8859-1',
  1138. 'german.iso88591': 'de_CH.ISO8859-1',
  1139. 'german_germany': 'de_DE.ISO8859-1',
  1140. 'german_germany.8859': 'de_DE.ISO8859-1',
  1141. 'gez_er': 'gez_ER.UTF-8',
  1142. 'gez_et': 'gez_ET.UTF-8',
  1143. 'gl': 'gl_ES.ISO8859-1',
  1144. 'gl_es': 'gl_ES.ISO8859-1',
  1145. 'gl_es.iso88591': 'gl_ES.ISO8859-1',
  1146. 'gl_es.iso885915': 'gl_ES.ISO8859-15',
  1147. 'gl_es.iso885915@euro': 'gl_ES.ISO8859-15',
  1148. 'gl_es.utf8@euro': 'gl_ES.UTF-8',
  1149. 'gl_es@euro': 'gl_ES.ISO8859-15',
  1150. 'greek': 'el_GR.ISO8859-7',
  1151. 'greek.iso88597': 'el_GR.ISO8859-7',
  1152. 'gu_in': 'gu_IN.UTF-8',
  1153. 'gv': 'gv_GB.ISO8859-1',
  1154. 'gv_gb': 'gv_GB.ISO8859-1',
  1155. 'gv_gb.iso88591': 'gv_GB.ISO8859-1',
  1156. 'gv_gb.iso885914': 'gv_GB.ISO8859-14',
  1157. 'gv_gb.iso885915': 'gv_GB.ISO8859-15',
  1158. 'gv_gb@euro': 'gv_GB.ISO8859-15',
  1159. 'ha_ng': 'ha_NG.UTF-8',
  1160. 'he': 'he_IL.ISO8859-8',
  1161. 'he_il': 'he_IL.ISO8859-8',
  1162. 'he_il.cp1255': 'he_IL.CP1255',
  1163. 'he_il.iso88598': 'he_IL.ISO8859-8',
  1164. 'he_il.microsoftcp1255': 'he_IL.CP1255',
  1165. 'hebrew': 'he_IL.ISO8859-8',
  1166. 'hebrew.iso88598': 'he_IL.ISO8859-8',
  1167. 'hi': 'hi_IN.ISCII-DEV',
  1168. 'hi_in': 'hi_IN.ISCII-DEV',
  1169. 'hi_in.isciidev': 'hi_IN.ISCII-DEV',
  1170. 'hne': 'hne_IN.UTF-8',
  1171. 'hne_in': 'hne_IN.UTF-8',
  1172. 'hr': 'hr_HR.ISO8859-2',
  1173. 'hr_hr': 'hr_HR.ISO8859-2',
  1174. 'hr_hr.iso88592': 'hr_HR.ISO8859-2',
  1175. 'hrvatski': 'hr_HR.ISO8859-2',
  1176. 'hsb_de': 'hsb_DE.ISO8859-2',
  1177. 'ht_ht': 'ht_HT.UTF-8',
  1178. 'hu': 'hu_HU.ISO8859-2',
  1179. 'hu_hu': 'hu_HU.ISO8859-2',
  1180. 'hu_hu.iso88592': 'hu_HU.ISO8859-2',
  1181. 'hungarian': 'hu_HU.ISO8859-2',
  1182. 'hy_am': 'hy_AM.UTF-8',
  1183. 'hy_am.armscii8': 'hy_AM.ARMSCII_8',
  1184. 'ia': 'ia.UTF-8',
  1185. 'ia_fr': 'ia_FR.UTF-8',
  1186. 'icelandic': 'is_IS.ISO8859-1',
  1187. 'icelandic.iso88591': 'is_IS.ISO8859-1',
  1188. 'id': 'id_ID.ISO8859-1',
  1189. 'id_id': 'id_ID.ISO8859-1',
  1190. 'ig_ng': 'ig_NG.UTF-8',
  1191. 'ik_ca': 'ik_CA.UTF-8',
  1192. 'in': 'id_ID.ISO8859-1',
  1193. 'in_id': 'id_ID.ISO8859-1',
  1194. 'is': 'is_IS.ISO8859-1',
  1195. 'is_is': 'is_IS.ISO8859-1',
  1196. 'is_is.iso88591': 'is_IS.ISO8859-1',
  1197. 'is_is.iso885915': 'is_IS.ISO8859-15',
  1198. 'is_is@euro': 'is_IS.ISO8859-15',
  1199. 'iso-8859-1': 'en_US.ISO8859-1',
  1200. 'iso-8859-15': 'en_US.ISO8859-15',
  1201. 'iso8859-1': 'en_US.ISO8859-1',
  1202. 'iso8859-15': 'en_US.ISO8859-15',
  1203. 'iso_8859_1': 'en_US.ISO8859-1',
  1204. 'iso_8859_15': 'en_US.ISO8859-15',
  1205. 'it': 'it_IT.ISO8859-1',
  1206. 'it.iso885915': 'it_IT.ISO8859-15',
  1207. 'it_ch': 'it_CH.ISO8859-1',
  1208. 'it_ch.iso88591': 'it_CH.ISO8859-1',
  1209. 'it_ch.iso885915': 'it_CH.ISO8859-15',
  1210. 'it_ch@euro': 'it_CH.ISO8859-15',
  1211. 'it_it': 'it_IT.ISO8859-1',
  1212. 'it_it.88591': 'it_IT.ISO8859-1',
  1213. 'it_it.iso88591': 'it_IT.ISO8859-1',
  1214. 'it_it.iso885915': 'it_IT.ISO8859-15',
  1215. 'it_it.iso885915@euro': 'it_IT.ISO8859-15',
  1216. 'it_it.utf8@euro': 'it_IT.UTF-8',
  1217. 'it_it@euro': 'it_IT.ISO8859-15',
  1218. 'italian': 'it_IT.ISO8859-1',
  1219. 'italian.iso88591': 'it_IT.ISO8859-1',
  1220. 'iu': 'iu_CA.NUNACOM-8',
  1221. 'iu_ca': 'iu_CA.NUNACOM-8',
  1222. 'iu_ca.nunacom8': 'iu_CA.NUNACOM-8',
  1223. 'iw': 'he_IL.ISO8859-8',
  1224. 'iw_il': 'he_IL.ISO8859-8',
  1225. 'iw_il.iso88598': 'he_IL.ISO8859-8',
  1226. 'iw_il.utf8': 'iw_IL.UTF-8',
  1227. 'ja': 'ja_JP.eucJP',
  1228. 'ja.jis': 'ja_JP.JIS7',
  1229. 'ja.sjis': 'ja_JP.SJIS',
  1230. 'ja_jp': 'ja_JP.eucJP',
  1231. 'ja_jp.ajec': 'ja_JP.eucJP',
  1232. 'ja_jp.euc': 'ja_JP.eucJP',
  1233. 'ja_jp.eucjp': 'ja_JP.eucJP',
  1234. 'ja_jp.iso-2022-jp': 'ja_JP.JIS7',
  1235. 'ja_jp.iso2022jp': 'ja_JP.JIS7',
  1236. 'ja_jp.jis': 'ja_JP.JIS7',
  1237. 'ja_jp.jis7': 'ja_JP.JIS7',
  1238. 'ja_jp.mscode': 'ja_JP.SJIS',
  1239. 'ja_jp.pck': 'ja_JP.SJIS',
  1240. 'ja_jp.sjis': 'ja_JP.SJIS',
  1241. 'ja_jp.ujis': 'ja_JP.eucJP',
  1242. 'japan': 'ja_JP.eucJP',
  1243. 'japanese': 'ja_JP.eucJP',
  1244. 'japanese-euc': 'ja_JP.eucJP',
  1245. 'japanese.euc': 'ja_JP.eucJP',
  1246. 'japanese.sjis': 'ja_JP.SJIS',
  1247. 'jp_jp': 'ja_JP.eucJP',
  1248. 'ka': 'ka_GE.GEORGIAN-ACADEMY',
  1249. 'ka_ge': 'ka_GE.GEORGIAN-ACADEMY',
  1250. 'ka_ge.georgianacademy': 'ka_GE.GEORGIAN-ACADEMY',
  1251. 'ka_ge.georgianps': 'ka_GE.GEORGIAN-PS',
  1252. 'ka_ge.georgianrs': 'ka_GE.GEORGIAN-ACADEMY',
  1253. 'kk_kz': 'kk_KZ.RK1048',
  1254. 'kl': 'kl_GL.ISO8859-1',
  1255. 'kl_gl': 'kl_GL.ISO8859-1',
  1256. 'kl_gl.iso88591': 'kl_GL.ISO8859-1',
  1257. 'kl_gl.iso885915': 'kl_GL.ISO8859-15',
  1258. 'kl_gl@euro': 'kl_GL.ISO8859-15',
  1259. 'km_kh': 'km_KH.UTF-8',
  1260. 'kn': 'kn_IN.UTF-8',
  1261. 'kn_in': 'kn_IN.UTF-8',
  1262. 'ko': 'ko_KR.eucKR',
  1263. 'ko_kr': 'ko_KR.eucKR',
  1264. 'ko_kr.euc': 'ko_KR.eucKR',
  1265. 'ko_kr.euckr': 'ko_KR.eucKR',
  1266. 'kok_in': 'kok_IN.UTF-8',
  1267. 'korean': 'ko_KR.eucKR',
  1268. 'korean.euc': 'ko_KR.eucKR',
  1269. 'ks': 'ks_IN.UTF-8',
  1270. 'ks_in': 'ks_IN.UTF-8',
  1271. 'ks_in@devanagari': 'ks_IN.UTF-8@devanagari',
  1272. 'ks_in@devanagari.utf8': 'ks_IN.UTF-8@devanagari',
  1273. 'ku_tr': 'ku_TR.ISO8859-9',
  1274. 'kw': 'kw_GB.ISO8859-1',
  1275. 'kw_gb': 'kw_GB.ISO8859-1',
  1276. 'kw_gb.iso88591': 'kw_GB.ISO8859-1',
  1277. 'kw_gb.iso885914': 'kw_GB.ISO8859-14',
  1278. 'kw_gb.iso885915': 'kw_GB.ISO8859-15',
  1279. 'kw_gb@euro': 'kw_GB.ISO8859-15',
  1280. 'ky': 'ky_KG.UTF-8',
  1281. 'ky_kg': 'ky_KG.UTF-8',
  1282. 'lb_lu': 'lb_LU.UTF-8',
  1283. 'lg_ug': 'lg_UG.ISO8859-10',
  1284. 'li_be': 'li_BE.UTF-8',
  1285. 'li_nl': 'li_NL.UTF-8',
  1286. 'lij_it': 'lij_IT.UTF-8',
  1287. 'lithuanian': 'lt_LT.ISO8859-13',
  1288. 'lo': 'lo_LA.MULELAO-1',
  1289. 'lo_la': 'lo_LA.MULELAO-1',
  1290. 'lo_la.cp1133': 'lo_LA.IBM-CP1133',
  1291. 'lo_la.ibmcp1133': 'lo_LA.IBM-CP1133',
  1292. 'lo_la.mulelao1': 'lo_LA.MULELAO-1',
  1293. 'lt': 'lt_LT.ISO8859-13',
  1294. 'lt_lt': 'lt_LT.ISO8859-13',
  1295. 'lt_lt.iso885913': 'lt_LT.ISO8859-13',
  1296. 'lt_lt.iso88594': 'lt_LT.ISO8859-4',
  1297. 'lv': 'lv_LV.ISO8859-13',
  1298. 'lv_lv': 'lv_LV.ISO8859-13',
  1299. 'lv_lv.iso885913': 'lv_LV.ISO8859-13',
  1300. 'lv_lv.iso88594': 'lv_LV.ISO8859-4',
  1301. 'mag_in': 'mag_IN.UTF-8',
  1302. 'mai': 'mai_IN.UTF-8',
  1303. 'mai_in': 'mai_IN.UTF-8',
  1304. 'mg_mg': 'mg_MG.ISO8859-15',
  1305. 'mhr_ru': 'mhr_RU.UTF-8',
  1306. 'mi': 'mi_NZ.ISO8859-1',
  1307. 'mi_nz': 'mi_NZ.ISO8859-1',
  1308. 'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
  1309. 'mk': 'mk_MK.ISO8859-5',
  1310. 'mk_mk': 'mk_MK.ISO8859-5',
  1311. 'mk_mk.cp1251': 'mk_MK.CP1251',
  1312. 'mk_mk.iso88595': 'mk_MK.ISO8859-5',
  1313. 'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
  1314. 'ml': 'ml_IN.UTF-8',
  1315. 'ml_in': 'ml_IN.UTF-8',
  1316. 'mn_mn': 'mn_MN.UTF-8',
  1317. 'mni_in': 'mni_IN.UTF-8',
  1318. 'mr': 'mr_IN.UTF-8',
  1319. 'mr_in': 'mr_IN.UTF-8',
  1320. 'ms': 'ms_MY.ISO8859-1',
  1321. 'ms_my': 'ms_MY.ISO8859-1',
  1322. 'ms_my.iso88591': 'ms_MY.ISO8859-1',
  1323. 'mt': 'mt_MT.ISO8859-3',
  1324. 'mt_mt': 'mt_MT.ISO8859-3',
  1325. 'mt_mt.iso88593': 'mt_MT.ISO8859-3',
  1326. 'my_mm': 'my_MM.UTF-8',
  1327. 'nan_tw@latin': 'nan_TW.UTF-8@latin',
  1328. 'nb': 'nb_NO.ISO8859-1',
  1329. 'nb_no': 'nb_NO.ISO8859-1',
  1330. 'nb_no.88591': 'nb_NO.ISO8859-1',
  1331. 'nb_no.iso88591': 'nb_NO.ISO8859-1',
  1332. 'nb_no.iso885915': 'nb_NO.ISO8859-15',
  1333. 'nb_no@euro': 'nb_NO.ISO8859-15',
  1334. 'nds_de': 'nds_DE.UTF-8',
  1335. 'nds_nl': 'nds_NL.UTF-8',
  1336. 'ne_np': 'ne_NP.UTF-8',
  1337. 'nhn_mx': 'nhn_MX.UTF-8',
  1338. 'niu_nu': 'niu_NU.UTF-8',
  1339. 'niu_nz': 'niu_NZ.UTF-8',
  1340. 'nl': 'nl_NL.ISO8859-1',
  1341. 'nl.iso885915': 'nl_NL.ISO8859-15',
  1342. 'nl_aw': 'nl_AW.UTF-8',
  1343. 'nl_be': 'nl_BE.ISO8859-1',
  1344. 'nl_be.88591': 'nl_BE.ISO8859-1',
  1345. 'nl_be.iso88591': 'nl_BE.ISO8859-1',
  1346. 'nl_be.iso885915': 'nl_BE.ISO8859-15',
  1347. 'nl_be.iso885915@euro': 'nl_BE.ISO8859-15',
  1348. 'nl_be.utf8@euro': 'nl_BE.UTF-8',
  1349. 'nl_be@euro': 'nl_BE.ISO8859-15',
  1350. 'nl_nl': 'nl_NL.ISO8859-1',
  1351. 'nl_nl.88591': 'nl_NL.ISO8859-1',
  1352. 'nl_nl.iso88591': 'nl_NL.ISO8859-1',
  1353. 'nl_nl.iso885915': 'nl_NL.ISO8859-15',
  1354. 'nl_nl.iso885915@euro': 'nl_NL.ISO8859-15',
  1355. 'nl_nl.utf8@euro': 'nl_NL.UTF-8',
  1356. 'nl_nl@euro': 'nl_NL.ISO8859-15',
  1357. 'nn': 'nn_NO.ISO8859-1',
  1358. 'nn_no': 'nn_NO.ISO8859-1',
  1359. 'nn_no.88591': 'nn_NO.ISO8859-1',
  1360. 'nn_no.iso88591': 'nn_NO.ISO8859-1',
  1361. 'nn_no.iso885915': 'nn_NO.ISO8859-15',
  1362. 'nn_no@euro': 'nn_NO.ISO8859-15',
  1363. 'no': 'no_NO.ISO8859-1',
  1364. 'no@nynorsk': 'ny_NO.ISO8859-1',
  1365. 'no_no': 'no_NO.ISO8859-1',
  1366. 'no_no.88591': 'no_NO.ISO8859-1',
  1367. 'no_no.iso88591': 'no_NO.ISO8859-1',
  1368. 'no_no.iso885915': 'no_NO.ISO8859-15',
  1369. 'no_no.iso88591@bokmal': 'no_NO.ISO8859-1',
  1370. 'no_no.iso88591@nynorsk': 'no_NO.ISO8859-1',
  1371. 'no_no@euro': 'no_NO.ISO8859-15',
  1372. 'norwegian': 'no_NO.ISO8859-1',
  1373. 'norwegian.iso88591': 'no_NO.ISO8859-1',
  1374. 'nr': 'nr_ZA.ISO8859-1',
  1375. 'nr_za': 'nr_ZA.ISO8859-1',
  1376. 'nr_za.iso88591': 'nr_ZA.ISO8859-1',
  1377. 'nso': 'nso_ZA.ISO8859-15',
  1378. 'nso_za': 'nso_ZA.ISO8859-15',
  1379. 'nso_za.iso885915': 'nso_ZA.ISO8859-15',
  1380. 'ny': 'ny_NO.ISO8859-1',
  1381. 'ny_no': 'ny_NO.ISO8859-1',
  1382. 'ny_no.88591': 'ny_NO.ISO8859-1',
  1383. 'ny_no.iso88591': 'ny_NO.ISO8859-1',
  1384. 'ny_no.iso885915': 'ny_NO.ISO8859-15',
  1385. 'ny_no@euro': 'ny_NO.ISO8859-15',
  1386. 'nynorsk': 'nn_NO.ISO8859-1',
  1387. 'oc': 'oc_FR.ISO8859-1',
  1388. 'oc_fr': 'oc_FR.ISO8859-1',
  1389. 'oc_fr.iso88591': 'oc_FR.ISO8859-1',
  1390. 'oc_fr.iso885915': 'oc_FR.ISO8859-15',
  1391. 'oc_fr@euro': 'oc_FR.ISO8859-15',
  1392. 'om_et': 'om_ET.UTF-8',
  1393. 'om_ke': 'om_KE.ISO8859-1',
  1394. 'or': 'or_IN.UTF-8',
  1395. 'or_in': 'or_IN.UTF-8',
  1396. 'os_ru': 'os_RU.UTF-8',
  1397. 'pa': 'pa_IN.UTF-8',
  1398. 'pa_in': 'pa_IN.UTF-8',
  1399. 'pa_pk': 'pa_PK.UTF-8',
  1400. 'pap_an': 'pap_AN.UTF-8',
  1401. 'pd': 'pd_US.ISO8859-1',
  1402. 'pd_de': 'pd_DE.ISO8859-1',
  1403. 'pd_de.iso88591': 'pd_DE.ISO8859-1',
  1404. 'pd_de.iso885915': 'pd_DE.ISO8859-15',
  1405. 'pd_de@euro': 'pd_DE.ISO8859-15',
  1406. 'pd_us': 'pd_US.ISO8859-1',
  1407. 'pd_us.iso88591': 'pd_US.ISO8859-1',
  1408. 'pd_us.iso885915': 'pd_US.ISO8859-15',
  1409. 'pd_us@euro': 'pd_US.ISO8859-15',
  1410. 'ph': 'ph_PH.ISO8859-1',
  1411. 'ph_ph': 'ph_PH.ISO8859-1',
  1412. 'ph_ph.iso88591': 'ph_PH.ISO8859-1',
  1413. 'pl': 'pl_PL.ISO8859-2',
  1414. 'pl_pl': 'pl_PL.ISO8859-2',
  1415. 'pl_pl.iso88592': 'pl_PL.ISO8859-2',
  1416. 'polish': 'pl_PL.ISO8859-2',
  1417. 'portuguese': 'pt_PT.ISO8859-1',
  1418. 'portuguese.iso88591': 'pt_PT.ISO8859-1',
  1419. 'portuguese_brazil': 'pt_BR.ISO8859-1',
  1420. 'portuguese_brazil.8859': 'pt_BR.ISO8859-1',
  1421. 'posix': 'C',
  1422. 'posix-utf2': 'C',
  1423. 'pp': 'pp_AN.ISO8859-1',
  1424. 'pp_an': 'pp_AN.ISO8859-1',
  1425. 'pp_an.iso88591': 'pp_AN.ISO8859-1',
  1426. 'ps_af': 'ps_AF.UTF-8',
  1427. 'pt': 'pt_PT.ISO8859-1',
  1428. 'pt.iso885915': 'pt_PT.ISO8859-15',
  1429. 'pt_br': 'pt_BR.ISO8859-1',
  1430. 'pt_br.88591': 'pt_BR.ISO8859-1',
  1431. 'pt_br.iso88591': 'pt_BR.ISO8859-1',
  1432. 'pt_br.iso885915': 'pt_BR.ISO8859-15',
  1433. 'pt_br@euro': 'pt_BR.ISO8859-15',
  1434. 'pt_pt': 'pt_PT.ISO8859-1',
  1435. 'pt_pt.88591': 'pt_PT.ISO8859-1',
  1436. 'pt_pt.iso88591': 'pt_PT.ISO8859-1',
  1437. 'pt_pt.iso885915': 'pt_PT.ISO8859-15',
  1438. 'pt_pt.iso885915@euro': 'pt_PT.ISO8859-15',
  1439. 'pt_pt.utf8@euro': 'pt_PT.UTF-8',
  1440. 'pt_pt@euro': 'pt_PT.ISO8859-15',
  1441. 'ro': 'ro_RO.ISO8859-2',
  1442. 'ro_ro': 'ro_RO.ISO8859-2',
  1443. 'ro_ro.iso88592': 'ro_RO.ISO8859-2',
  1444. 'romanian': 'ro_RO.ISO8859-2',
  1445. 'ru': 'ru_RU.UTF-8',
  1446. 'ru.koi8r': 'ru_RU.KOI8-R',
  1447. 'ru_ru': 'ru_RU.UTF-8',
  1448. 'ru_ru.cp1251': 'ru_RU.CP1251',
  1449. 'ru_ru.iso88595': 'ru_RU.ISO8859-5',
  1450. 'ru_ru.koi8r': 'ru_RU.KOI8-R',
  1451. 'ru_ru.microsoftcp1251': 'ru_RU.CP1251',
  1452. 'ru_ua': 'ru_UA.KOI8-U',
  1453. 'ru_ua.cp1251': 'ru_UA.CP1251',
  1454. 'ru_ua.koi8u': 'ru_UA.KOI8-U',
  1455. 'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
  1456. 'rumanian': 'ro_RO.ISO8859-2',
  1457. 'russian': 'ru_RU.ISO8859-5',
  1458. 'rw': 'rw_RW.ISO8859-1',
  1459. 'rw_rw': 'rw_RW.ISO8859-1',
  1460. 'rw_rw.iso88591': 'rw_RW.ISO8859-1',
  1461. 'sa_in': 'sa_IN.UTF-8',
  1462. 'sat_in': 'sat_IN.UTF-8',
  1463. 'sc_it': 'sc_IT.UTF-8',
  1464. 'sd': 'sd_IN.UTF-8',
  1465. 'sd@devanagari': 'sd_IN.UTF-8@devanagari',
  1466. 'sd_in': 'sd_IN.UTF-8',
  1467. 'sd_in@devanagari': 'sd_IN.UTF-8@devanagari',
  1468. 'sd_in@devanagari.utf8': 'sd_IN.UTF-8@devanagari',
  1469. 'sd_pk': 'sd_PK.UTF-8',
  1470. 'se_no': 'se_NO.UTF-8',
  1471. 'serbocroatian': 'sr_RS.UTF-8@latin',
  1472. 'sh': 'sr_RS.UTF-8@latin',
  1473. 'sh_ba.iso88592@bosnia': 'sr_CS.ISO8859-2',
  1474. 'sh_hr': 'sh_HR.ISO8859-2',
  1475. 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
  1476. 'sh_sp': 'sr_CS.ISO8859-2',
  1477. 'sh_yu': 'sr_RS.UTF-8@latin',
  1478. 'shs_ca': 'shs_CA.UTF-8',
  1479. 'si': 'si_LK.UTF-8',
  1480. 'si_lk': 'si_LK.UTF-8',
  1481. 'sid_et': 'sid_ET.UTF-8',
  1482. 'sinhala': 'si_LK.UTF-8',
  1483. 'sk': 'sk_SK.ISO8859-2',
  1484. 'sk_sk': 'sk_SK.ISO8859-2',
  1485. 'sk_sk.iso88592': 'sk_SK.ISO8859-2',
  1486. 'sl': 'sl_SI.ISO8859-2',
  1487. 'sl_cs': 'sl_CS.ISO8859-2',
  1488. 'sl_si': 'sl_SI.ISO8859-2',
  1489. 'sl_si.iso88592': 'sl_SI.ISO8859-2',
  1490. 'slovak': 'sk_SK.ISO8859-2',
  1491. 'slovene': 'sl_SI.ISO8859-2',
  1492. 'slovenian': 'sl_SI.ISO8859-2',
  1493. 'so_dj': 'so_DJ.ISO8859-1',
  1494. 'so_et': 'so_ET.UTF-8',
  1495. 'so_ke': 'so_KE.ISO8859-1',
  1496. 'so_so': 'so_SO.ISO8859-1',
  1497. 'sp': 'sr_CS.ISO8859-5',
  1498. 'sp_yu': 'sr_CS.ISO8859-5',
  1499. 'spanish': 'es_ES.ISO8859-1',
  1500. 'spanish.iso88591': 'es_ES.ISO8859-1',
  1501. 'spanish_spain': 'es_ES.ISO8859-1',
  1502. 'spanish_spain.8859': 'es_ES.ISO8859-1',
  1503. 'sq': 'sq_AL.ISO8859-2',
  1504. 'sq_al': 'sq_AL.ISO8859-2',
  1505. 'sq_al.iso88592': 'sq_AL.ISO8859-2',
  1506. 'sq_mk': 'sq_MK.UTF-8',
  1507. 'sr': 'sr_RS.UTF-8',
  1508. 'sr@cyrillic': 'sr_RS.UTF-8',
  1509. 'sr@latin': 'sr_RS.UTF-8@latin',
  1510. 'sr@latn': 'sr_CS.UTF-8@latin',
  1511. 'sr_cs': 'sr_CS.UTF-8',
  1512. 'sr_cs.iso88592': 'sr_CS.ISO8859-2',
  1513. 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
  1514. 'sr_cs.iso88595': 'sr_CS.ISO8859-5',
  1515. 'sr_cs.utf8@latn': 'sr_CS.UTF-8@latin',
  1516. 'sr_cs@latn': 'sr_CS.UTF-8@latin',
  1517. 'sr_me': 'sr_ME.UTF-8',
  1518. 'sr_rs': 'sr_RS.UTF-8',
  1519. 'sr_rs@latin': 'sr_RS.UTF-8@latin',
  1520. 'sr_rs@latn': 'sr_RS.UTF-8@latin',
  1521. 'sr_sp': 'sr_CS.ISO8859-2',
  1522. 'sr_yu': 'sr_RS.UTF-8@latin',
  1523. 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
  1524. 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
  1525. 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
  1526. 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
  1527. 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
  1528. 'sr_yu.utf8': 'sr_RS.UTF-8',
  1529. 'sr_yu.utf8@cyrillic': 'sr_RS.UTF-8',
  1530. 'sr_yu@cyrillic': 'sr_RS.UTF-8',
  1531. 'ss': 'ss_ZA.ISO8859-1',
  1532. 'ss_za': 'ss_ZA.ISO8859-1',
  1533. 'ss_za.iso88591': 'ss_ZA.ISO8859-1',
  1534. 'st': 'st_ZA.ISO8859-1',
  1535. 'st_za': 'st_ZA.ISO8859-1',
  1536. 'st_za.iso88591': 'st_ZA.ISO8859-1',
  1537. 'sv': 'sv_SE.ISO8859-1',
  1538. 'sv.iso885915': 'sv_SE.ISO8859-15',
  1539. 'sv_fi': 'sv_FI.ISO8859-1',
  1540. 'sv_fi.iso88591': 'sv_FI.ISO8859-1',
  1541. 'sv_fi.iso885915': 'sv_FI.ISO8859-15',
  1542. 'sv_fi.iso885915@euro': 'sv_FI.ISO8859-15',
  1543. 'sv_fi.utf8@euro': 'sv_FI.UTF-8',
  1544. 'sv_fi@euro': 'sv_FI.ISO8859-15',
  1545. 'sv_se': 'sv_SE.ISO8859-1',
  1546. 'sv_se.88591': 'sv_SE.ISO8859-1',
  1547. 'sv_se.iso88591': 'sv_SE.ISO8859-1',
  1548. 'sv_se.iso885915': 'sv_SE.ISO8859-15',
  1549. 'sv_se@euro': 'sv_SE.ISO8859-15',
  1550. 'sw_ke': 'sw_KE.UTF-8',
  1551. 'sw_tz': 'sw_TZ.UTF-8',
  1552. 'swedish': 'sv_SE.ISO8859-1',
  1553. 'swedish.iso88591': 'sv_SE.ISO8859-1',
  1554. 'szl_pl': 'szl_PL.UTF-8',
  1555. 'ta': 'ta_IN.TSCII-0',
  1556. 'ta_in': 'ta_IN.TSCII-0',
  1557. 'ta_in.tscii': 'ta_IN.TSCII-0',
  1558. 'ta_in.tscii0': 'ta_IN.TSCII-0',
  1559. 'ta_lk': 'ta_LK.UTF-8',
  1560. 'te': 'te_IN.UTF-8',
  1561. 'te_in': 'te_IN.UTF-8',
  1562. 'tg': 'tg_TJ.KOI8-C',
  1563. 'tg_tj': 'tg_TJ.KOI8-C',
  1564. 'tg_tj.koi8c': 'tg_TJ.KOI8-C',
  1565. 'th': 'th_TH.ISO8859-11',
  1566. 'th_th': 'th_TH.ISO8859-11',
  1567. 'th_th.iso885911': 'th_TH.ISO8859-11',
  1568. 'th_th.tactis': 'th_TH.TIS620',
  1569. 'th_th.tis620': 'th_TH.TIS620',
  1570. 'thai': 'th_TH.ISO8859-11',
  1571. 'ti_er': 'ti_ER.UTF-8',
  1572. 'ti_et': 'ti_ET.UTF-8',
  1573. 'tig_er': 'tig_ER.UTF-8',
  1574. 'tk_tm': 'tk_TM.UTF-8',
  1575. 'tl': 'tl_PH.ISO8859-1',
  1576. 'tl_ph': 'tl_PH.ISO8859-1',
  1577. 'tl_ph.iso88591': 'tl_PH.ISO8859-1',
  1578. 'tn': 'tn_ZA.ISO8859-15',
  1579. 'tn_za': 'tn_ZA.ISO8859-15',
  1580. 'tn_za.iso885915': 'tn_ZA.ISO8859-15',
  1581. 'tr': 'tr_TR.ISO8859-9',
  1582. 'tr_cy': 'tr_CY.ISO8859-9',
  1583. 'tr_tr': 'tr_TR.ISO8859-9',
  1584. 'tr_tr.iso88599': 'tr_TR.ISO8859-9',
  1585. 'ts': 'ts_ZA.ISO8859-1',
  1586. 'ts_za': 'ts_ZA.ISO8859-1',
  1587. 'ts_za.iso88591': 'ts_ZA.ISO8859-1',
  1588. 'tt': 'tt_RU.TATAR-CYR',
  1589. 'tt_ru': 'tt_RU.TATAR-CYR',
  1590. 'tt_ru.koi8c': 'tt_RU.KOI8-C',
  1591. 'tt_ru.tatarcyr': 'tt_RU.TATAR-CYR',
  1592. 'tt_ru@iqtelif': 'tt_RU.UTF-8@iqtelif',
  1593. 'turkish': 'tr_TR.ISO8859-9',
  1594. 'turkish.iso88599': 'tr_TR.ISO8859-9',
  1595. 'ug_cn': 'ug_CN.UTF-8',
  1596. 'uk': 'uk_UA.KOI8-U',
  1597. 'uk_ua': 'uk_UA.KOI8-U',
  1598. 'uk_ua.cp1251': 'uk_UA.CP1251',
  1599. 'uk_ua.iso88595': 'uk_UA.ISO8859-5',
  1600. 'uk_ua.koi8u': 'uk_UA.KOI8-U',
  1601. 'uk_ua.microsoftcp1251': 'uk_UA.CP1251',
  1602. 'univ': 'en_US.utf',
  1603. 'universal': 'en_US.utf',
  1604. 'universal.utf8@ucs4': 'en_US.UTF-8',
  1605. 'unm_us': 'unm_US.UTF-8',
  1606. 'ur': 'ur_PK.CP1256',
  1607. 'ur_in': 'ur_IN.UTF-8',
  1608. 'ur_pk': 'ur_PK.CP1256',
  1609. 'ur_pk.cp1256': 'ur_PK.CP1256',
  1610. 'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
  1611. 'uz': 'uz_UZ.UTF-8',
  1612. 'uz_uz': 'uz_UZ.UTF-8',
  1613. 'uz_uz.iso88591': 'uz_UZ.ISO8859-1',
  1614. 'uz_uz.utf8@cyrillic': 'uz_UZ.UTF-8',
  1615. 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
  1616. 've': 've_ZA.UTF-8',
  1617. 've_za': 've_ZA.UTF-8',
  1618. 'vi': 'vi_VN.TCVN',
  1619. 'vi_vn': 'vi_VN.TCVN',
  1620. 'vi_vn.tcvn': 'vi_VN.TCVN',
  1621. 'vi_vn.tcvn5712': 'vi_VN.TCVN',
  1622. 'vi_vn.viscii': 'vi_VN.VISCII',
  1623. 'vi_vn.viscii111': 'vi_VN.VISCII',
  1624. 'wa': 'wa_BE.ISO8859-1',
  1625. 'wa_be': 'wa_BE.ISO8859-1',
  1626. 'wa_be.iso88591': 'wa_BE.ISO8859-1',
  1627. 'wa_be.iso885915': 'wa_BE.ISO8859-15',
  1628. 'wa_be.iso885915@euro': 'wa_BE.ISO8859-15',
  1629. 'wa_be@euro': 'wa_BE.ISO8859-15',
  1630. 'wae_ch': 'wae_CH.UTF-8',
  1631. 'wal_et': 'wal_ET.UTF-8',
  1632. 'wo_sn': 'wo_SN.UTF-8',
  1633. 'xh': 'xh_ZA.ISO8859-1',
  1634. 'xh_za': 'xh_ZA.ISO8859-1',
  1635. 'xh_za.iso88591': 'xh_ZA.ISO8859-1',
  1636. 'yi': 'yi_US.CP1255',
  1637. 'yi_us': 'yi_US.CP1255',
  1638. 'yi_us.cp1255': 'yi_US.CP1255',
  1639. 'yi_us.microsoftcp1255': 'yi_US.CP1255',
  1640. 'yo_ng': 'yo_NG.UTF-8',
  1641. 'yue_hk': 'yue_HK.UTF-8',
  1642. 'zh': 'zh_CN.eucCN',
  1643. 'zh_cn': 'zh_CN.gb2312',
  1644. 'zh_cn.big5': 'zh_TW.big5',
  1645. 'zh_cn.euc': 'zh_CN.eucCN',
  1646. 'zh_cn.gb18030': 'zh_CN.gb18030',
  1647. 'zh_cn.gb2312': 'zh_CN.gb2312',
  1648. 'zh_cn.gbk': 'zh_CN.gbk',
  1649. 'zh_hk': 'zh_HK.big5hkscs',
  1650. 'zh_hk.big5': 'zh_HK.big5',
  1651. 'zh_hk.big5hk': 'zh_HK.big5hkscs',
  1652. 'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
  1653. 'zh_sg': 'zh_SG.GB2312',
  1654. 'zh_sg.gbk': 'zh_SG.GBK',
  1655. 'zh_tw': 'zh_TW.big5',
  1656. 'zh_tw.big5': 'zh_TW.big5',
  1657. 'zh_tw.euc': 'zh_TW.eucTW',
  1658. 'zh_tw.euctw': 'zh_TW.eucTW',
  1659. 'zu': 'zu_ZA.ISO8859-1',
  1660. 'zu_za': 'zu_ZA.ISO8859-1',
  1661. 'zu_za.iso88591': 'zu_ZA.ISO8859-1',
  1662. }
  1663. #
  1664. # This maps Windows language identifiers to locale strings.
  1665. #
  1666. # This list has been updated from
  1667. # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp
  1668. # to include every locale up to Windows Vista.
  1669. #
  1670. # NOTE: this mapping is incomplete. If your language is missing, please
  1671. # submit a bug report to the Python bug tracker at http://bugs.python.org/
  1672. # Make sure you include the missing language identifier and the suggested
  1673. # locale code.
  1674. #
  1675. windows_locale = {
  1676. 0x0436: "af_ZA", # Afrikaans
  1677. 0x041c: "sq_AL", # Albanian
  1678. 0x0484: "gsw_FR",# Alsatian - France
  1679. 0x045e: "am_ET", # Amharic - Ethiopia
  1680. 0x0401: "ar_SA", # Arabic - Saudi Arabia
  1681. 0x0801: "ar_IQ", # Arabic - Iraq
  1682. 0x0c01: "ar_EG", # Arabic - Egypt
  1683. 0x1001: "ar_LY", # Arabic - Libya
  1684. 0x1401: "ar_DZ", # Arabic - Algeria
  1685. 0x1801: "ar_MA", # Arabic - Morocco
  1686. 0x1c01: "ar_TN", # Arabic - Tunisia
  1687. 0x2001: "ar_OM", # Arabic - Oman
  1688. 0x2401: "ar_YE", # Arabic - Yemen
  1689. 0x2801: "ar_SY", # Arabic - Syria
  1690. 0x2c01: "ar_JO", # Arabic - Jordan
  1691. 0x3001: "ar_LB", # Arabic - Lebanon
  1692. 0x3401: "ar_KW", # Arabic - Kuwait
  1693. 0x3801: "ar_AE", # Arabic - United Arab Emirates
  1694. 0x3c01: "ar_BH", # Arabic - Bahrain
  1695. 0x4001: "ar_QA", # Arabic - Qatar
  1696. 0x042b: "hy_AM", # Armenian
  1697. 0x044d: "as_IN", # Assamese - India
  1698. 0x042c: "az_AZ", # Azeri - Latin
  1699. 0x082c: "az_AZ", # Azeri - Cyrillic
  1700. 0x046d: "ba_RU", # Bashkir
  1701. 0x042d: "eu_ES", # Basque - Russia
  1702. 0x0423: "be_BY", # Belarusian
  1703. 0x0445: "bn_IN", # Begali
  1704. 0x201a: "bs_BA", # Bosnian - Cyrillic
  1705. 0x141a: "bs_BA", # Bosnian - Latin
  1706. 0x047e: "br_FR", # Breton - France
  1707. 0x0402: "bg_BG", # Bulgarian
  1708. # 0x0455: "my_MM", # Burmese - Not supported
  1709. 0x0403: "ca_ES", # Catalan
  1710. 0x0004: "zh_CHS",# Chinese - Simplified
  1711. 0x0404: "zh_TW", # Chinese - Taiwan
  1712. 0x0804: "zh_CN", # Chinese - PRC
  1713. 0x0c04: "zh_HK", # Chinese - Hong Kong S.A.R.
  1714. 0x1004: "zh_SG", # Chinese - Singapore
  1715. 0x1404: "zh_MO", # Chinese - Macao S.A.R.
  1716. 0x7c04: "zh_CHT",# Chinese - Traditional
  1717. 0x0483: "co_FR", # Corsican - France
  1718. 0x041a: "hr_HR", # Croatian
  1719. 0x101a: "hr_BA", # Croatian - Bosnia
  1720. 0x0405: "cs_CZ", # Czech
  1721. 0x0406: "da_DK", # Danish
  1722. 0x048c: "gbz_AF",# Dari - Afghanistan
  1723. 0x0465: "div_MV",# Divehi - Maldives
  1724. 0x0413: "nl_NL", # Dutch - The Netherlands
  1725. 0x0813: "nl_BE", # Dutch - Belgium
  1726. 0x0409: "en_US", # English - United States
  1727. 0x0809: "en_GB", # English - United Kingdom
  1728. 0x0c09: "en_AU", # English - Australia
  1729. 0x1009: "en_CA", # English - Canada
  1730. 0x1409: "en_NZ", # English - New Zealand
  1731. 0x1809: "en_IE", # English - Ireland
  1732. 0x1c09: "en_ZA", # English - South Africa
  1733. 0x2009: "en_JA", # English - Jamaica
  1734. 0x2409: "en_CB", # English - Caribbean
  1735. 0x2809: "en_BZ", # English - Belize
  1736. 0x2c09: "en_TT", # English - Trinidad
  1737. 0x3009: "en_ZW", # English - Zimbabwe
  1738. 0x3409: "en_PH", # English - Philippines
  1739. 0x4009: "en_IN", # English - India
  1740. 0x4409: "en_MY", # English - Malaysia
  1741. 0x4809: "en_IN", # English - Singapore
  1742. 0x0425: "et_EE", # Estonian
  1743. 0x0438: "fo_FO", # Faroese
  1744. 0x0464: "fil_PH",# Filipino
  1745. 0x040b: "fi_FI", # Finnish
  1746. 0x040c: "fr_FR", # French - France
  1747. 0x080c: "fr_BE", # French - Belgium
  1748. 0x0c0c: "fr_CA", # French - Canada
  1749. 0x100c: "fr_CH", # French - Switzerland
  1750. 0x140c: "fr_LU", # French - Luxembourg
  1751. 0x180c: "fr_MC", # French - Monaco
  1752. 0x0462: "fy_NL", # Frisian - Netherlands
  1753. 0x0456: "gl_ES", # Galician
  1754. 0x0437: "ka_GE", # Georgian
  1755. 0x0407: "de_DE", # German - Germany
  1756. 0x0807: "de_CH", # German - Switzerland
  1757. 0x0c07: "de_AT", # German - Austria
  1758. 0x1007: "de_LU", # German - Luxembourg
  1759. 0x1407: "de_LI", # German - Liechtenstein
  1760. 0x0408: "el_GR", # Greek
  1761. 0x046f: "kl_GL", # Greenlandic - Greenland
  1762. 0x0447: "gu_IN", # Gujarati
  1763. 0x0468: "ha_NG", # Hausa - Latin
  1764. 0x040d: "he_IL", # Hebrew
  1765. 0x0439: "hi_IN", # Hindi
  1766. 0x040e: "hu_HU", # Hungarian
  1767. 0x040f: "is_IS", # Icelandic
  1768. 0x0421: "id_ID", # Indonesian
  1769. 0x045d: "iu_CA", # Inuktitut - Syllabics
  1770. 0x085d: "iu_CA", # Inuktitut - Latin
  1771. 0x083c: "ga_IE", # Irish - Ireland
  1772. 0x0410: "it_IT", # Italian - Italy
  1773. 0x0810: "it_CH", # Italian - Switzerland
  1774. 0x0411: "ja_JP", # Japanese
  1775. 0x044b: "kn_IN", # Kannada - India
  1776. 0x043f: "kk_KZ", # Kazakh
  1777. 0x0453: "kh_KH", # Khmer - Cambodia
  1778. 0x0486: "qut_GT",# K'iche - Guatemala
  1779. 0x0487: "rw_RW", # Kinyarwanda - Rwanda
  1780. 0x0457: "kok_IN",# Konkani
  1781. 0x0412: "ko_KR", # Korean
  1782. 0x0440: "ky_KG", # Kyrgyz
  1783. 0x0454: "lo_LA", # Lao - Lao PDR
  1784. 0x0426: "lv_LV", # Latvian
  1785. 0x0427: "lt_LT", # Lithuanian
  1786. 0x082e: "dsb_DE",# Lower Sorbian - Germany
  1787. 0x046e: "lb_LU", # Luxembourgish
  1788. 0x042f: "mk_MK", # FYROM Macedonian
  1789. 0x043e: "ms_MY", # Malay - Malaysia
  1790. 0x083e: "ms_BN", # Malay - Brunei Darussalam
  1791. 0x044c: "ml_IN", # Malayalam - India
  1792. 0x043a: "mt_MT", # Maltese
  1793. 0x0481: "mi_NZ", # Maori
  1794. 0x047a: "arn_CL",# Mapudungun
  1795. 0x044e: "mr_IN", # Marathi
  1796. 0x047c: "moh_CA",# Mohawk - Canada
  1797. 0x0450: "mn_MN", # Mongolian - Cyrillic
  1798. 0x0850: "mn_CN", # Mongolian - PRC
  1799. 0x0461: "ne_NP", # Nepali
  1800. 0x0414: "nb_NO", # Norwegian - Bokmal
  1801. 0x0814: "nn_NO", # Norwegian - Nynorsk
  1802. 0x0482: "oc_FR", # Occitan - France
  1803. 0x0448: "or_IN", # Oriya - India
  1804. 0x0463: "ps_AF", # Pashto - Afghanistan
  1805. 0x0429: "fa_IR", # Persian
  1806. 0x0415: "pl_PL", # Polish
  1807. 0x0416: "pt_BR", # Portuguese - Brazil
  1808. 0x0816: "pt_PT", # Portuguese - Portugal
  1809. 0x0446: "pa_IN", # Punjabi
  1810. 0x046b: "quz_BO",# Quechua (Bolivia)
  1811. 0x086b: "quz_EC",# Quechua (Ecuador)
  1812. 0x0c6b: "quz_PE",# Quechua (Peru)
  1813. 0x0418: "ro_RO", # Romanian - Romania
  1814. 0x0417: "rm_CH", # Romansh
  1815. 0x0419: "ru_RU", # Russian
  1816. 0x243b: "smn_FI",# Sami Finland
  1817. 0x103b: "smj_NO",# Sami Norway
  1818. 0x143b: "smj_SE",# Sami Sweden
  1819. 0x043b: "se_NO", # Sami Northern Norway
  1820. 0x083b: "se_SE", # Sami Northern Sweden
  1821. 0x0c3b: "se_FI", # Sami Northern Finland
  1822. 0x203b: "sms_FI",# Sami Skolt
  1823. 0x183b: "sma_NO",# Sami Southern Norway
  1824. 0x1c3b: "sma_SE",# Sami Southern Sweden
  1825. 0x044f: "sa_IN", # Sanskrit
  1826. 0x0c1a: "sr_SP", # Serbian - Cyrillic
  1827. 0x1c1a: "sr_BA", # Serbian - Bosnia Cyrillic
  1828. 0x081a: "sr_SP", # Serbian - Latin
  1829. 0x181a: "sr_BA", # Serbian - Bosnia Latin
  1830. 0x045b: "si_LK", # Sinhala - Sri Lanka
  1831. 0x046c: "ns_ZA", # Northern Sotho
  1832. 0x0432: "tn_ZA", # Setswana - Southern Africa
  1833. 0x041b: "sk_SK", # Slovak
  1834. 0x0424: "sl_SI", # Slovenian
  1835. 0x040a: "es_ES", # Spanish - Spain
  1836. 0x080a: "es_MX", # Spanish - Mexico
  1837. 0x0c0a: "es_ES", # Spanish - Spain (Modern)
  1838. 0x100a: "es_GT", # Spanish - Guatemala
  1839. 0x140a: "es_CR", # Spanish - Costa Rica
  1840. 0x180a: "es_PA", # Spanish - Panama
  1841. 0x1c0a: "es_DO", # Spanish - Dominican Republic
  1842. 0x200a: "es_VE", # Spanish - Venezuela
  1843. 0x240a: "es_CO", # Spanish - Colombia
  1844. 0x280a: "es_PE", # Spanish - Peru
  1845. 0x2c0a: "es_AR", # Spanish - Argentina
  1846. 0x300a: "es_EC", # Spanish - Ecuador
  1847. 0x340a: "es_CL", # Spanish - Chile
  1848. 0x380a: "es_UR", # Spanish - Uruguay
  1849. 0x3c0a: "es_PY", # Spanish - Paraguay
  1850. 0x400a: "es_BO", # Spanish - Bolivia
  1851. 0x440a: "es_SV", # Spanish - El Salvador
  1852. 0x480a: "es_HN", # Spanish - Honduras
  1853. 0x4c0a: "es_NI", # Spanish - Nicaragua
  1854. 0x500a: "es_PR", # Spanish - Puerto Rico
  1855. 0x540a: "es_US", # Spanish - United States
  1856. # 0x0430: "", # Sutu - Not supported
  1857. 0x0441: "sw_KE", # Swahili
  1858. 0x041d: "sv_SE", # Swedish - Sweden
  1859. 0x081d: "sv_FI", # Swedish - Finland
  1860. 0x045a: "syr_SY",# Syriac
  1861. 0x0428: "tg_TJ", # Tajik - Cyrillic
  1862. 0x085f: "tmz_DZ",# Tamazight - Latin
  1863. 0x0449: "ta_IN", # Tamil
  1864. 0x0444: "tt_RU", # Tatar
  1865. 0x044a: "te_IN", # Telugu
  1866. 0x041e: "th_TH", # Thai
  1867. 0x0851: "bo_BT", # Tibetan - Bhutan
  1868. 0x0451: "bo_CN", # Tibetan - PRC
  1869. 0x041f: "tr_TR", # Turkish
  1870. 0x0442: "tk_TM", # Turkmen - Cyrillic
  1871. 0x0480: "ug_CN", # Uighur - Arabic
  1872. 0x0422: "uk_UA", # Ukrainian
  1873. 0x042e: "wen_DE",# Upper Sorbian - Germany
  1874. 0x0420: "ur_PK", # Urdu
  1875. 0x0820: "ur_IN", # Urdu - India
  1876. 0x0443: "uz_UZ", # Uzbek - Latin
  1877. 0x0843: "uz_UZ", # Uzbek - Cyrillic
  1878. 0x042a: "vi_VN", # Vietnamese
  1879. 0x0452: "cy_GB", # Welsh
  1880. 0x0488: "wo_SN", # Wolof - Senegal
  1881. 0x0434: "xh_ZA", # Xhosa - South Africa
  1882. 0x0485: "sah_RU",# Yakut - Cyrillic
  1883. 0x0478: "ii_CN", # Yi - PRC
  1884. 0x046a: "yo_NG", # Yoruba - Nigeria
  1885. 0x0435: "zu_ZA", # Zulu
  1886. }
  1887. def _print_locale():
  1888. """ Test function.
  1889. """
  1890. categories = {}
  1891. def _init_categories(categories=categories):
  1892. for k,v in globals().items():
  1893. if k[:3] == 'LC_':
  1894. categories[k] = v
  1895. _init_categories()
  1896. del categories['LC_ALL']
  1897. print 'Locale defaults as determined by getdefaultlocale():'
  1898. print '-'*72
  1899. lang, enc = getdefaultlocale()
  1900. print 'Language: ', lang or '(undefined)'
  1901. print 'Encoding: ', enc or '(undefined)'
  1902. print
  1903. print 'Locale settings on startup:'
  1904. print '-'*72
  1905. for name,category in categories.items():
  1906. print name, '...'
  1907. lang, enc = getlocale(category)
  1908. print ' Language: ', lang or '(undefined)'
  1909. print ' Encoding: ', enc or '(undefined)'
  1910. print
  1911. print
  1912. print 'Locale settings after calling resetlocale():'
  1913. print '-'*72
  1914. resetlocale()
  1915. for name,category in categories.items():
  1916. print name, '...'
  1917. lang, enc = getlocale(category)
  1918. print ' Language: ', lang or '(undefined)'
  1919. print ' Encoding: ', enc or '(undefined)'
  1920. print
  1921. try:
  1922. setlocale(LC_ALL, "")
  1923. except:
  1924. print 'NOTE:'
  1925. print 'setlocale(LC_ALL, "") does not support the default locale'
  1926. print 'given in the OS environment variables.'
  1927. else:
  1928. print
  1929. print 'Locale settings after calling setlocale(LC_ALL, ""):'
  1930. print '-'*72
  1931. for name,category in categories.items():
  1932. print name, '...'
  1933. lang, enc = getlocale(category)
  1934. print ' Language: ', lang or '(undefined)'
  1935. print ' Encoding: ', enc or '(undefined)'
  1936. print
  1937. ###
  1938. try:
  1939. LC_MESSAGES
  1940. except NameError:
  1941. pass
  1942. else:
  1943. __all__.append("LC_MESSAGES")
  1944. if __name__=='__main__':
  1945. print 'Locale aliasing:'
  1946. print
  1947. _print_locale()
  1948. print
  1949. print 'Number formatting:'
  1950. print
  1951. _test()