This is a multi-part message in MIME format. --------------FDA69223F7CCDED3D7828E2B Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To make moving into the direction of making the string encoding depend on the locale settings a little easier, I've started to hack away at an extension of the locale.py module. The module provides enough information to be able to set the string encoding in site.py at startup. Additional code for _localemodule.c would be nice for platforms which use other APIs to get at the active code page, e.g. on Windows and Macs. Please try it on your platform and tell me what you think of the APIs. Thanks, -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ --------------FDA69223F7CCDED3D7828E2B Content-Type: text/python; charset=us-ascii; name="localex.py" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="localex.py" """ Extented locale.py This version of locale.py contains a locale aliasing engine and knows the default encoding of many common locales. (c) Marc-Andre Lemburg, mal@lemburg.com """ from locale import * import string __version__ = '0.1' ### APIs def normalize(localename): """ Returns a normalized locale code for the given locale name. The locale code is usable for setting the locale using setlocale(). If normalization fails, the original name is returned unchanged. """ lname = string.lower(localename) if ':' in lname: # ':' is sometimes used as encoding delimiter. lname = string.replace(lname, ':', '.') code = locale_alias.get(lname, localename) if code is localename: # Could be that the encoding is not known; in that case # we default to the default encoding for that locale code # just like setlocale() does. if '.' in lname: lname, encoding = string.split(lname, '.') code = locale_alias.get(lname, localename) return code def _parse_localename(localename): """ Parses the locale code for localename and returns the result as tuple (language code, encoding). The language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined. """ code = normalize(localename) l = string.split(code, '.') if len(l) != 2: if l[0] == 'C': return None,None else: raise SystemError,'error in locale.locale_alias: missing encoding' return l def get_default(): """ Tries to determine the default locale settings and returns them as tuple (language code, encoding). According to POSIX, a program which has not called setlocale(LC_ALL,"") runs using the portable 'C' locale. Calling setlocale(LC_ALL,"") lets it use the default locale as defined by the LANG variable. Since we don't want to interfere with the current locale setting we thus emulate the behaviour in the way described above. Except for the code 'C', the language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined. """ # XXX On some systems the environment variables LC_ALL, LC_CTYPE, etc. # complement the setting of LANG... perhaps we should try those # variables too ? import os localename = os.environ.get('LANG','C') return _parse_localename(localename) def get_locale(category=LC_CTYPE): """ Returns the current setting for the given locale category as tuple (language code, encoding). category may be one of the LC_* value except LC_ALL. It defaults to LC_CTYPE. Except for the code 'C', the language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined. """ return _parse_localename(setlocale(category)) def set_locale(localename, category=LC_ALL): """ Set the locale to localename. localename can be given as common locale name. It will be filtered through a list of common aliases for the C locale codes. category may be given as one of the LC_* values. It defaults to LC_ALL. """ setlocale(category, normalize(localename)) ### Data # # The following table was extracted from the locale.alias file which # comes with X11. It is usually available as # /usr/lib/X11/locale/locale.alias. # # The table maps lowercase alias names to C locale names. Encodings # are always separated from the locale name using a dot ('.'). # locale_alias = { 'american.iso88591': 'en_US.ISO8859-1', 'american.iso885915': 'en_US.ISO8859-15', 'ar': 'ar_AA.ISO8859-6', 'ar_aa': 'ar_AA.ISO8859-6', 'ar_sa.iso88596': 'ar_SA.ISO8859-6', 'arabic.iso88596': 'ar_AA.ISO8859-6', 'bg': 'bg_BG.ISO8859-5', 'bg_bg': 'bg_BG.ISO8859-5', 'bg_bg.iso88595': 'bg_BG.ISO8859-5', 'bulgarian': 'bg_BG.ISO8859-5', 'c-french.iso88591': 'fr_CA.ISO8859-1', 'c-french.iso885915': 'fr_CA.ISO8859-15', 'c.en': 'C', 'c.iso88591': 'en_US.ISO8859-1', 'c.iso885915': 'en_US.ISO8859-15', 'c_c.c': 'C', 'cextend': 'en_US.ISO8859-1', 'cextend.en': 'en_US.ISO8859-1', 'chinese-s': 'zh_CN.eucCN', 'chinese-t': 'zh_TW.eucTW', 'croatian': 'hr_HR.ISO8859-2', 'cs': 'cs_CZ.ISO8859-2', 'cs_cs': 'cs_CZ.ISO8859-2', 'cs_cs.iso8859-2': 'cs_CZ.ISO8859-2', 'cs_cz': 'cs_CZ.ISO8859-2', 'cs_cz.iso88592': 'cs_CZ.ISO8859-2', 'cz': 'cz_CZ.ISO8859-2', 'cz_cz': 'cz_CZ.ISO8859-2', 'czech': 'cs_CS.ISO8859-2', 'da': 'da_DK.ISO8859-1', 'da_dk': 'da_DK.ISO8859-1', 'da_dk.88591': 'da_DK.ISO8859-1', 'da_dk.88591.en': 'da_DK.ISO8859-1', 'da_dk.885915': 'da_DK.ISO8859-15', 'da_dk.885915.en': 'da_DK.ISO8859-15', 'da_dk.iso88591': 'da_DK.ISO8859-1', 'da_dk.iso885915': 'da_DK.ISO8859-15', 'da_dk.iso_8859-1': 'da_DK.ISO8859-1', 'da_dk.iso_8859-15': 'da_DK.ISO8859-15', 'danish.iso88591': 'da_DK.ISO8859-1', 'danish.iso885915': 'da_DK.ISO8859-15', 'de': 'de_DE.ISO8859-1', 'de_at': 'de_AT.ISO8859-1', 'de_at.iso_8859-1': 'de_AT.ISO8859-1', 'de_at.iso_8859-15': 'de_AT.ISO8859-15', 'de_ch': 'de_CH.ISO8859-1', 'de_ch.iso_8859-1': 'de_CH.ISO8859-1', 'de_ch.iso_8859-15': 'de_CH.ISO8859-15', 'de_de': 'de_DE.ISO8859-1', 'de_de.88591': 'de_DE.ISO8859-1', 'de_de.88591.en': 'de_DE.ISO8859-1', 'de_de.885915': 'de_DE.ISO8859-15', 'de_de.885915.en': 'de_DE.ISO8859-15', 'de_de.iso88591': 'de_DE.ISO8859-1', 'de_de.iso885915': 'de_DE.ISO8859-15', 'de_de.iso_8859-1': 'de_DE.ISO8859-1', 'de_de.iso_8859-15': 'de_DE.ISO8859-15', 'dutch.iso88591': 'nl_BE.ISO8859-1', 'dutch.iso885915': 'nl_BE.ISO8859-15', 'ee': 'ee_EE.ISO8859-4', 'el': 'el_GR.ISO8859-7', 'el_gr': 'el_GR.ISO8859-7', 'el_gr.iso88597': 'el_GR.ISO8859-7', 'en': 'en_US.ISO8859-1', 'en_au': 'en_AU.ISO8859-1', 'en_au.iso_8859-1': 'en_AU.ISO8859-1', 'en_au.iso_8859-15': 'en_AU.ISO8859-15', 'en_ca': 'en_CA.ISO8859-1', 'en_ca.iso_8859-1': 'en_CA.ISO8859-1', 'en_ca.iso_8859-15': 'en_CA.ISO8859-15', 'en_gb': 'en_GB.ISO8859-1', 'en_gb.88591': 'en_GB.ISO8859-1', 'en_gb.88591.en': 'en_GB.ISO8859-1', 'en_gb.885915': 'en_GB.ISO8859-15', 'en_gb.885915.en': 'en_GB.ISO8859-15', 'en_gb.iso88591': 'en_GB.ISO8859-1', 'en_gb.iso885915': 'en_GB.ISO8859-15', 'en_gb.iso_8859-1': 'en_GB.ISO8859-1', 'en_gb.iso_8859-15': 'en_GB.ISO8859-15', 'en_ie': 'en_IE.ISO8859-1', 'en_nz': 'en_NZ.ISO8859-1', 'en_uk': 'en_GB.ISO8859-1', 'en_us': 'en_US.ISO8859-1', 'en_us.88591': 'en_US.ISO8859-1', 'en_us.88591.en': 'en_US.ISO8859-1', 'en_us.885915': 'en_US.ISO8859-15', 'en_us.885915.en': 'en_US.ISO8859-15', 'en_us.iso88591': 'en_US.ISO8859-1', 'en_us.iso885915': 'en_US.ISO8859-15', 'en_us.iso_8859-1': 'en_US.ISO8859-1', 'en_us.iso_8859-15': 'en_US.ISO8859-15', 'en_us.utf-8': 'en_US.utf', 'en_us.utf-8': 'en_US.utf', 'eng_gb.8859': 'en_GB.ISO8859-1', 'eng_gb.8859.in': 'en_GB.ISO8859-1', 'english.iso88591': 'en_EN.ISO8859-1', 'english.iso885915': 'en_EN.ISO8859-15', 'english_uk.8859': 'en_GB.ISO8859-1', 'english_united-states.437': 'C', 'english_us.8859': 'en_US.ISO8859-1', 'english_us.ascii': 'en_US.ISO8859-1', 'es': 'es_ES.ISO8859-1', 'es_ar': 'es_AR.ISO8859-1', 'es_bo': 'es_BO.ISO8859-1', 'es_cl': 'es_CL.ISO8859-1', 'es_co': 'es_CO.ISO8859-1', 'es_cr': 'es_CR.ISO8859-1', 'es_ec': 'es_EC.ISO8859-1', 'es_es': 'es_ES.ISO8859-1', 'es_es.88591': 'es_ES.ISO8859-1', 'es_es.88591.en': 'es_ES.ISO8859-1', 'es_es.885915': 'es_ES.ISO8859-15', 'es_es.885915.en': 'es_ES.ISO8859-15', 'es_es.iso88591': 'es_ES.ISO8859-1', 'es_es.iso885915': 'es_ES.ISO8859-15', 'es_es.iso_8859-1': 'es_ES.ISO8859-1', 'es_es.iso_8859-15': 'es_ES.ISO8859-15', 'es_gt': 'es_GT.ISO8859-1', 'es_mx': 'es_MX.ISO8859-1', 'es_ni': 'es_NI.ISO8859-1', 'es_pa': 'es_PA.ISO8859-1', 'es_pe': 'es_PE.ISO8859-1', 'es_py': 'es_PY.ISO8859-1', 'es_sv': 'es_SV.ISO8859-1', 'es_uy': 'es_UY.ISO8859-1', 'es_ve': 'es_VE.ISO8859-1', 'et': 'et_EE.ISO8859-4', 'et_ee': 'et_EE.ISO8859-4', 'fi': 'fi_FI.ISO8859-1', 'fi_fi': 'fi_FI.ISO8859-1', 'fi_fi.88591': 'fi_FI.ISO8859-1', 'fi_fi.88591.en': 'fi_FI.ISO8859-1', 'fi_fi.885915': 'fi_FI.ISO8859-15', 'fi_fi.885915.en': 'fi_FI.ISO8859-15', 'fi_fi.iso88591': 'fi_FI.ISO8859-1', 'fi_fi.iso885915': 'fi_FI.ISO8859-15', 'fi_fi.iso_8859-1': 'fi_FI.ISO8859-1', 'fi_fi.iso_8859-15': 'fi_FI.ISO8859-15', 'finnish.iso88591': 'fi_FI.ISO8859-1', 'finnish.iso885915': 'fi_FI.ISO8859-15', 'fr': 'fr_FR.ISO8859-1', 'fr_be': 'fr_BE.ISO8859-1', 'fr_be.88591': 'fr_BE.ISO8859-1', 'fr_be.88591.en': 'fr_BE.ISO8859-1', 'fr_be.885915': 'fr_BE.ISO8859-15', 'fr_be.885915.en': 'fr_BE.ISO8859-15', 'fr_be.iso_8859-1': 'fr_BE.ISO8859-1', 'fr_be.iso_8859-15': 'fr_BE.ISO8859-15', 'fr_ca': 'fr_CA.ISO8859-1', 'fr_ca.88591': 'fr_CA.ISO8859-1', 'fr_ca.88591.en': 'fr_CA.ISO8859-1', 'fr_ca.885915': 'fr_CA.ISO8859-15', 'fr_ca.885915.en': 'fr_CA.ISO8859-15', 'fr_ca.iso88591': 'fr_CA.ISO8859-1', 'fr_ca.iso885915': 'fr_CA.ISO8859-15', 'fr_ca.iso_8859-1': 'fr_CA.ISO8859-1', 'fr_ca.iso_8859-15': 'fr_CA.ISO8859-15', 'fr_ch': 'fr_CH.ISO8859-1', 'fr_ch.88591': 'fr_CH.ISO8859-1', 'fr_ch.88591.en': 'fr_CH.ISO8859-1', 'fr_ch.885915': 'fr_CH.ISO8859-15', 'fr_ch.885915.en': 'fr_CH.ISO8859-15', 'fr_ch.iso_8859-1': 'fr_CH.ISO8859-1', 'fr_ch.iso_8859-15': 'fr_CH.ISO8859-15', 'fr_fr': 'fr_FR.ISO8859-1', 'fr_fr.88591': 'fr_FR.ISO8859-1', 'fr_fr.88591.en': 'fr_FR.ISO8859-1', 'fr_fr.885915': 'fr_FR.ISO8859-15', 'fr_fr.885915.en': 'fr_FR.ISO8859-15', 'fr_fr.iso88591': 'fr_FR.ISO8859-1', 'fr_fr.iso885915': 'fr_FR.ISO8859-15', 'fr_fr.iso_8859-1': 'fr_FR.ISO8859-1', 'fr_fr.iso_8859-15': 'fr_FR.ISO8859-15', 'fre_fr.8859': 'fr_FR.ISO8859-1', 'fre_fr.8859.in': 'fr_FR.ISO8859-1', 'french.iso88591': 'fr_CH.ISO8859-1', 'french.iso885915': 'fr_CH.ISO8859-15', 'french_france.8859': 'fr_FR.ISO8859-1', 'ger_de.8859': 'de_DE.ISO8859-1', 'ger_de.8859.in': 'de_DE.ISO8859-1', 'german.iso88591': 'de_CH.ISO8859-1', 'german.iso885915': 'de_CH.ISO8859-15', 'german_germany.8859': 'de_DE.ISO8859-1', 'greek.iso88597': 'el_GR.ISO8859-7', 'hebrew.iso88598': 'iw_IL.ISO8859-8', 'hr': 'hr_HR.ISO8859-2', 'hr_hr': 'hr_HR.ISO8859-2', 'hr_hr.iso88592': 'hr_HR.ISO8859-2', 'hr_hr.iso_8859-2': 'hr_HR.ISO8859-2', 'hu': 'hu_HU.ISO8859-2', 'hu_hu': 'hu_HU.ISO8859-2', 'hu_hu.iso88592': 'hu_HU.ISO8859-2', 'hungarian': 'hu_HU.ISO8859-2', 'icelandic.iso88591': 'is_IS.ISO8859-1', 'icelandic.iso885915': 'is_IS.ISO8859-15', 'id': 'id_ID.ISO8859-1', 'id_id': 'id_ID.ISO8859-1', 'id_id.iso88591': 'id_ID.ISO8859-1', 'is': 'is_IS.ISO8859-1', 'is_is': 'is_IS.ISO8859-1', 'is_is.iso88591': 'is_IS.ISO8859-1', 'is_is.iso885915': 'is_IS.ISO8859-15', 'is_is.iso_8859-1': 'is_IS.ISO8859-1', 'is_is.iso_8859-15': 'is_IS.ISO8859-15', 'iso-8859-1': 'en_US.ISO8859-1', 'iso-8859-15': 'en_US.ISO8859-15', 'iso8859-1': 'en_US.ISO8859-1', 'iso8859-15': 'en_US.ISO8859-15', 'iso_8859_1': 'en_US.ISO8859-1', 'iso_8859_15': 'en_US.ISO8859-15', 'it': 'it_IT.ISO8859-1', 'it_ch': 'it_CH.ISO8859-1', 'it_ch.iso_8859-1': 'it_CH.ISO8859-1', 'it_ch.iso_8859-15': 'it_CH.ISO8859-15', 'it_it': 'it_IT.ISO8859-1', 'it_it.88591': 'it_IT.ISO8859-1', 'it_it.88591.en': 'it_IT.ISO8859-1', 'it_it.885915': 'it_IT.ISO8859-15', 'it_it.885915.en': 'it_IT.ISO8859-15', 'it_it.iso88591': 'it_IT.ISO8859-1', 'it_it.iso885915': 'it_IT.ISO8859-15', 'it_it.iso_8859-1': 'it_IT.ISO8859-1', 'it_it.iso_8859-15': 'it_IT.ISO8859-15', 'italian.iso88591': 'it_IT.ISO8859-1', 'italian.iso885915': 'it_IT.ISO8859-15', 'iw': 'iw_IL.ISO8859-8', 'iw_il': 'iw_IL.ISO8859-8', 'iw_il.iso88598': 'iw_IL.ISO8859-8', 'ja': 'ja_JP.eucJP', 'ja.jis': 'ja_JP.JIS7', 'ja.sjis': 'ja_JP.SJIS', 'ja_jp': 'ja_JP.eucJP', 'ja_jp.ajec': 'ja_JP.eucJP', 'ja_jp.euc': 'ja_JP.eucJP', 'ja_jp.eucjp': 'ja_JP.eucJP', 'ja_jp.iso-2022-jp': 'ja_JP.JIS7', 'ja_jp.jis': 'ja_JP.JIS7', 'ja_jp.jis7': 'ja_JP.JIS7', 'ja_jp.mscode': 'ja_JP.SJIS', 'ja_jp.sjis': 'ja_JP.SJIS', 'ja_jp.ujis': 'ja_JP.eucJP', 'japan': 'ja_JP.eucJP', 'japanese': 'ja_JP.SJIS', 'japanese-euc': 'ja_JP.eucJP', 'japanese.euc': 'ja_JP.eucJP', 'jp_jp': 'ja_JP.eucJP', 'ko': 'ko_KR.eucKR', 'ko_kr': 'ko_KR.eucKR', 'ko_kr.euc': 'ko_KR.eucKR', 'ko_kr.euc': 'ko_KR.eucKR', 'korean': 'ko_KR.eucKR', 'lt': 'lt_LT.ISO8859-4', 'lv': 'lv_LV.ISO8859-4', 'mk': 'mk_MK.ISO8859-5', 'mk_mk': 'mk_MK.ISO8859-5', 'nl': 'nl_NL.ISO8859-1', 'nl_be': 'nl_BE.ISO8859-1', 'nl_be.88591': 'nl_BE.ISO8859-1', 'nl_be.88591.en': 'nl_BE.ISO8859-1', 'nl_be.885915': 'nl_BE.ISO8859-15', 'nl_be.885915.en': 'nl_BE.ISO8859-15', 'nl_be.iso_8859-1': 'nl_BE.ISO8859-1', 'nl_be.iso_8859-15': 'nl_BE.ISO8859-15', 'nl_nl': 'nl_NL.ISO8859-1', 'nl_nl.88591': 'nl_NL.ISO8859-1', 'nl_nl.88591.en': 'nl_NL.ISO8859-1', 'nl_nl.885915': 'nl_NL.ISO8859-15', 'nl_nl.885915.en': 'nl_NL.ISO8859-15', 'nl_nl.iso88591': 'nl_NL.ISO8859-1', 'nl_nl.iso885915': 'nl_NL.ISO8859-15', 'nl_nl.iso_8859-1': 'nl_NL.ISO8859-1', 'nl_nl.iso_8859-15': 'nl_NL.ISO8859-15', 'no': 'no_NO.ISO8859-1', 'no_no': 'no_NO.ISO8859-1', 'no_no.88591': 'no_NO.ISO8859-1', 'no_no.88591.en': 'no_NO.ISO8859-1', 'no_no.885915': 'no_NO.ISO8859-15', 'no_no.885915.en': 'no_NO.ISO8859-15', 'no_no.iso88591': 'no_NO.ISO8859-1', 'no_no.iso885915': 'no_NO.ISO8859-15', 'no_no.iso_8859-1': 'no_NO.ISO8859-1', 'no_no.iso_8859-15': 'no_NO.ISO8859-15', 'norwegian.iso88591': 'no_NO.ISO8859-1', 'norwegian.iso885915': 'no_NO.ISO8859-15', 'pl': 'pl_PL.ISO8859-2', 'pl_pl': 'pl_PL.ISO8859-2', 'pl_pl.iso88592': 'pl_PL.ISO8859-2', 'polish': 'pl_PL.ISO8859-2', 'portuguese.iso88591': 'pt_PT.ISO8859-1', 'portuguese.iso885915': 'pt_PT.ISO8859-15', 'portuguese_brazil.8859': 'pt_BR.ISO8859-1', 'posix': 'C', 'posix-utf2': 'C', 'pt': 'pt_PT.ISO8859-1', 'pt_br': 'pt_BR.ISO8859-1', 'pt_pt': 'pt_PT.ISO8859-1', 'pt_pt.88591': 'pt_PT.ISO8859-1', 'pt_pt.88591.en': 'pt_PT.ISO8859-1', 'pt_pt.885915': 'pt_PT.ISO8859-15', 'pt_pt.885915.en': 'pt_PT.ISO8859-15', 'pt_pt.iso88591': 'pt_PT.ISO8859-1', 'pt_pt.iso885915': 'pt_PT.ISO8859-15', 'pt_pt.iso_8859-1': 'pt_PT.ISO8859-1', 'pt_pt.iso_8859-15': 'pt_PT.ISO8859-15', 'ro': 'ro_RO.ISO8859-2', 'ro_ro': 'ro_RO.ISO8859-2', 'ro_ro.iso88592': 'ro_RO.ISO8859-2', 'ru': 'ru_RU.ISO8859-5', 'ru_ru': 'ru_RU.ISO8859-5', 'ru_ru.iso88595': 'ru_RU.ISO8859-5', 'rumanian': 'ro_RO.ISO8859-2', 'russian': 'ru_RU.ISO8859-5', 'serbocroatian': 'sh_YU.ISO8859-2', 'sh': 'sh_YU.ISO8859-2', 'sh_hr.iso88592': 'sh_HR.ISO8859-2', 'sh_sp': 'sh_YU.ISO8859-2', 'sh_yu': 'sh_YU.ISO8859-2', 'sk': 'sk_SK.ISO8859-2', 'sk_sk': 'sk_SK.ISO8859-2', 'sk_sk.iso88592': 'sk_SK.ISO8859-2', 'sl': 'sl_CS.ISO8859-2', 'sl_cs': 'sl_CS.ISO8859-2', 'sl_si': 'sl_SI.ISO8859-2', 'sl_si.iso88592': 'sl_SI.ISO8859-2', 'slovak': 'sk_SK.ISO8859-2', 'slovene': 'sl_CS.ISO8859-2', 'sp': 'sp_YU.ISO8859-5', 'sp_yu': 'sp_YU.ISO8859-5', 'spanish.iso88591': 'es_ES.ISO8859-1', 'spanish.iso885915': 'es_ES.ISO8859-15', 'spanish_spain.8859': 'es_ES.ISO8859-1', 'sr_sp': 'sr_SP.ISO8859-2', 'sv': 'sv_SE.ISO8859-1', 'sv_se': 'sv_SE.ISO8859-1', 'sv_se.88591': 'sv_SE.ISO8859-1', 'sv_se.88591.en': 'sv_SE.ISO8859-1', 'sv_se.885915': 'sv_SE.ISO8859-15', 'sv_se.885915.en': 'sv_SE.ISO8859-15', 'sv_se.iso88591': 'sv_SE.ISO8859-1', 'sv_se.iso885915': 'sv_SE.ISO8859-15', 'sv_se.iso_8859-1': 'sv_SE.ISO8859-1', 'sv_se.iso_8859-15': 'sv_SE.ISO8859-15', 'swedish.iso88591': 'sv_SE.ISO8859-1', 'swedish.iso885915': 'sv_SE.ISO8859-15', 'th_th': 'th_TH.TACTIS', 'th_th.tis620': 'th_TH.TACTIS', 'tr': 'tr_TR.ISO8859-9', 'tr_tr': 'tr_TR.ISO8859-9', 'tr_tr.iso88599': 'tr_TR.ISO8859-9', 'turkish.iso88599': 'tr_TR.ISO8859-9', 'univ.utf8': 'en_US.utf', 'universal.utf8@ucs4': 'en_US.utf', 'zh': 'zh_CN.eucCN', 'zh_cn': 'zh_CN.eucCN', 'zh_cn.big5': 'zh_TW.eucTW', 'zh_cn.euc': 'zh_CN.eucCN', 'zh_tw': 'zh_TW.eucTW', 'zh_tw.euc': 'zh_TW.eucTW', } if __name__ == '__main__': categories = {} def _init_categories(): for k,v in globals().items(): if k[:3] == 'LC_': categories[k] = v _init_categories() print 'Locale defaults:' print '-'*72 lang, enc = get_default() print 'Language: ', lang or '(undefined)' print 'Encoding: ', enc or '(undefined)' print print 'Locale settings on startup:' print '-'*72 for name,category in categories.items(): print name,'...' lang, enc = get_locale(category) print ' Language: ', lang or '(undefined)' print ' Encoding: ', enc or '(undefined)' print setlocale(LC_ALL,"") print print 'Locale settings after calling setlocale(LC_ALL,""):' print '-'*72 for name,category in categories.items(): print name,'...' lang, enc = get_locale(category) print ' Language: ', lang or '(undefined)' print ' Encoding: ', enc or '(undefined)' print --------------FDA69223F7CCDED3D7828E2B--
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4