Python encodings.aliases() Examples
The following are 30
code examples of encodings.aliases().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
encodings
, or try the search function
.

Example #1
Source File: locale.py From python with Apache License 2.0 | 6 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = norm_encoding norm_encoding = norm_encoding.lower() if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] else: norm_encoding = norm_encoding.replace('_', '') norm_encoding = norm_encoding.replace('-', '') if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #2
Source File: locale.py From odoo13-x64 with GNU General Public License v3.0 | 6 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = norm_encoding norm_encoding = norm_encoding.lower() if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] else: norm_encoding = norm_encoding.replace('_', '') norm_encoding = norm_encoding.replace('-', '') if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #3
Source File: locale.py From scylla with Apache License 2.0 | 6 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = norm_encoding norm_encoding = norm_encoding.lower() if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] else: norm_encoding = norm_encoding.replace('_', '') norm_encoding = norm_encoding.replace('-', '') if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #4
Source File: locale.py From Imogen with MIT License | 6 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = norm_encoding norm_encoding = norm_encoding.lower() if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] else: norm_encoding = norm_encoding.replace('_', '') norm_encoding = norm_encoding.replace('-', '') if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #5
Source File: locale.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = norm_encoding norm_encoding = norm_encoding.lower() if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] else: norm_encoding = norm_encoding.replace('_', '') norm_encoding = norm_encoding.replace('-', '') if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #6
Source File: locale.py From ironpython3 with Apache License 2.0 | 6 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = norm_encoding norm_encoding = norm_encoding.lower() if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] else: norm_encoding = norm_encoding.replace('_', '') norm_encoding = norm_encoding.replace('-', '') if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #7
Source File: locale.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = norm_encoding norm_encoding = norm_encoding.lower() if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] else: norm_encoding = norm_encoding.replace('_', '') norm_encoding = norm_encoding.replace('-', '') if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #8
Source File: locale.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = norm_encoding norm_encoding = norm_encoding.lower() if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] else: norm_encoding = norm_encoding.replace('_', '') norm_encoding = norm_encoding.replace('-', '') if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #9
Source File: locale.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = norm_encoding norm_encoding = norm_encoding.lower() if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] else: norm_encoding = norm_encoding.replace('_', '') norm_encoding = norm_encoding.replace('-', '') if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #10
Source File: locale.py From android_universal with MIT License | 6 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = norm_encoding norm_encoding = norm_encoding.lower() if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] else: norm_encoding = norm_encoding.replace('_', '') norm_encoding = norm_encoding.replace('-', '') if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #11
Source File: locale.py From python2017 with MIT License | 6 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = norm_encoding norm_encoding = norm_encoding.lower() if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] else: norm_encoding = norm_encoding.replace('_', '') norm_encoding = norm_encoding.replace('-', '') if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #12
Source File: locale.py From kobo-predict with BSD 2-Clause "Simplified" License | 6 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(), norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = norm_encoding norm_encoding = norm_encoding.lower() if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] else: norm_encoding = norm_encoding.replace('_', '') norm_encoding = norm_encoding.replace('-', '') if norm_encoding in locale_encoding_alias: encoding = locale_encoding_alias[norm_encoding] #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #13
Source File: locale.py From PhonePi_SampleServer with MIT License | 5 votes |
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" if do_setlocale: oldloc = setlocale(LC_CTYPE) try: setlocale(LC_CTYPE, "") except Error: pass result = nl_langinfo(CODESET) setlocale(LC_CTYPE, oldloc) return result else: return nl_langinfo(CODESET) ### Database # # The following data was extracted from the locale.alias file which # comes with X11 and then hand edited removing the explicit encoding # definitions and adding some more aliases. The file is usually # available as /usr/lib/X11/locale/locale.alias. # # # The local_encoding_alias table maps lowercase encoding alias names # to C locale encoding names (case-sensitive). Note that normalize() # first looks up the encoding in the encodings.aliases dictionary and # then applies this mapping to find the correct C lib name for the # encoding. #
Example #14
Source File: locale.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" import _bootlocale if do_setlocale: oldloc = setlocale(LC_CTYPE) try: setlocale(LC_CTYPE, "") except Error: pass result = _bootlocale.getpreferredencoding(False) if do_setlocale: setlocale(LC_CTYPE, oldloc) return result ### Database # # The following data was extracted from the locale.alias file which # comes with X11 and then hand edited removing the explicit encoding # definitions and adding some more aliases. The file is usually # available as /usr/lib/X11/locale/locale.alias. # # # The local_encoding_alias table maps lowercase encoding alias names # to C locale encoding names (case-sensitive). Note that normalize() # first looks up the encoding in the encodings.aliases dictionary and # then applies this mapping to find the correct C lib name for the # encoding. #
Example #15
Source File: locale.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" if do_setlocale: oldloc = setlocale(LC_CTYPE) try: setlocale(LC_CTYPE, "") except Error: pass result = nl_langinfo(CODESET) setlocale(LC_CTYPE, oldloc) return result else: return nl_langinfo(CODESET) ### Database # # The following data was extracted from the locale.alias file which # comes with X11 and then hand edited removing the explicit encoding # definitions and adding some more aliases. The file is usually # available as /usr/lib/X11/locale/locale.alias. # # # The local_encoding_alias table maps lowercase encoding alias names # to C locale encoding names (case-sensitive). Note that normalize() # first looks up the encoding in the encodings.aliases dictionary and # then applies this mapping to find the correct C lib name for the # encoding. #
Example #16
Source File: locale.py From PhonePi_SampleServer with MIT License | 5 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding, norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = locale_encoding_alias.get(norm_encoding, norm_encoding) #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #17
Source File: locale.py From medicare-demo with Apache License 2.0 | 5 votes |
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" if do_setlocale: oldloc = setlocale(LC_CTYPE) setlocale(LC_CTYPE, "") result = nl_langinfo(CODESET) setlocale(LC_CTYPE, oldloc) return result else: return nl_langinfo(CODESET) ### Database # # The following data was extracted from the locale.alias file which # comes with X11 and then hand edited removing the explicit encoding # definitions and adding some more aliases. The file is usually # available as /usr/lib/X11/locale/locale.alias. # # # The local_encoding_alias table maps lowercase encoding alias names # to C locale encoding names (case-sensitive). Note that normalize() # first looks up the encoding in the encodings.aliases dictionary and # then applies this mapping to find the correct C lib name for the # encoding. #
Example #18
Source File: locale.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" if do_setlocale: oldloc = setlocale(LC_CTYPE) try: setlocale(LC_CTYPE, "") except Error: pass result = nl_langinfo(CODESET) setlocale(LC_CTYPE, oldloc) return result else: return nl_langinfo(CODESET) ### Database # # The following data was extracted from the locale.alias file which # comes with X11 and then hand edited removing the explicit encoding # definitions and adding some more aliases. The file is usually # available as /usr/lib/X11/locale/locale.alias. # # # The local_encoding_alias table maps lowercase encoding alias names # to C locale encoding names (case-sensitive). Note that normalize() # first looks up the encoding in the encodings.aliases dictionary and # then applies this mapping to find the correct C lib name for the # encoding. #
Example #19
Source File: locale.py From syntheticmass with Apache License 2.0 | 5 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding, norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = locale_encoding_alias.get(norm_encoding, norm_encoding) #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #20
Source File: locale.py From syntheticmass with Apache License 2.0 | 5 votes |
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" if do_setlocale: oldloc = setlocale(LC_CTYPE) try: setlocale(LC_CTYPE, "") except Error: pass result = nl_langinfo(CODESET) setlocale(LC_CTYPE, oldloc) return result else: return nl_langinfo(CODESET) ### Database # # The following data was extracted from the locale.alias file which # comes with X11 and then hand edited removing the explicit encoding # definitions and adding some more aliases. The file is usually # available as /usr/lib/X11/locale/locale.alias. # # # The local_encoding_alias table maps lowercase encoding alias names # to C locale encoding names (case-sensitive). Note that normalize() # first looks up the encoding in the encodings.aliases dictionary and # then applies this mapping to find the correct C lib name for the # encoding. #
Example #21
Source File: locale.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding, norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = locale_encoding_alias.get(norm_encoding, norm_encoding) #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #22
Source File: locale.py From datafari with Apache License 2.0 | 5 votes |
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" if do_setlocale: oldloc = setlocale(LC_CTYPE) try: setlocale(LC_CTYPE, "") except Error: pass result = nl_langinfo(CODESET) setlocale(LC_CTYPE, oldloc) return result else: return nl_langinfo(CODESET) ### Database # # The following data was extracted from the locale.alias file which # comes with X11 and then hand edited removing the explicit encoding # definitions and adding some more aliases. The file is usually # available as /usr/lib/X11/locale/locale.alias. # # # The local_encoding_alias table maps lowercase encoding alias names # to C locale encoding names (case-sensitive). Note that normalize() # first looks up the encoding in the encodings.aliases dictionary and # then applies this mapping to find the correct C lib name for the # encoding. #
Example #23
Source File: locale.py From odoo13-x64 with GNU General Public License v3.0 | 5 votes |
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" if sys.flags.utf8_mode: return 'UTF-8' import _bootlocale if do_setlocale: oldloc = setlocale(LC_CTYPE) try: setlocale(LC_CTYPE, "") except Error: pass result = _bootlocale.getpreferredencoding(False) if do_setlocale: setlocale(LC_CTYPE, oldloc) return result ### Database # # The following data was extracted from the locale.alias file which # comes with X11 and then hand edited removing the explicit encoding # definitions and adding some more aliases. The file is usually # available as /usr/lib/X11/locale/locale.alias. # # # The local_encoding_alias table maps lowercase encoding alias names # to C locale encoding names (case-sensitive). Note that normalize() # first looks up the encoding in the encodings.aliases dictionary and # then applies this mapping to find the correct C lib name for the # encoding. #
Example #24
Source File: locale.py From ImageFusion with MIT License | 5 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding, norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = locale_encoding_alias.get(norm_encoding, norm_encoding) #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #25
Source File: locale.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" if do_setlocale: oldloc = setlocale(LC_CTYPE) try: setlocale(LC_CTYPE, "") except Error: pass result = nl_langinfo(CODESET) setlocale(LC_CTYPE, oldloc) return result else: return nl_langinfo(CODESET) ### Database # # The following data was extracted from the locale.alias file which # comes with X11 and then hand edited removing the explicit encoding # definitions and adding some more aliases. The file is usually # available as /usr/lib/X11/locale/locale.alias. # # # The local_encoding_alias table maps lowercase encoding alias names # to C locale encoding names (case-sensitive). Note that normalize() # first looks up the encoding in the encodings.aliases dictionary and # then applies this mapping to find the correct C lib name for the # encoding. #
Example #26
Source File: locale.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" if do_setlocale: oldloc = setlocale(LC_CTYPE) try: setlocale(LC_CTYPE, "") except Error: pass result = nl_langinfo(CODESET) setlocale(LC_CTYPE, oldloc) return result else: return nl_langinfo(CODESET) ### Database # # The following data was extracted from the locale.alias file which # comes with X11 and then hand edited removing the explicit encoding # definitions and adding some more aliases. The file is usually # available as /usr/lib/X11/locale/locale.alias. # # # The local_encoding_alias table maps lowercase encoding alias names # to C locale encoding names (case-sensitive). Note that normalize() # first looks up the encoding in the encodings.aliases dictionary and # then applies this mapping to find the correct C lib name for the # encoding. #
Example #27
Source File: locale.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" if sys.flags.utf8_mode: return 'UTF-8' import _bootlocale if do_setlocale: oldloc = setlocale(LC_CTYPE) try: setlocale(LC_CTYPE, "") except Error: pass result = _bootlocale.getpreferredencoding(False) if do_setlocale: setlocale(LC_CTYPE, oldloc) return result ### Database # # The following data was extracted from the locale.alias file which # comes with X11 and then hand edited removing the explicit encoding # definitions and adding some more aliases. The file is usually # available as /usr/lib/X11/locale/locale.alias. # # # The local_encoding_alias table maps lowercase encoding alias names # to C locale encoding names (case-sensitive). Note that normalize() # first looks up the encoding in the encodings.aliases dictionary and # then applies this mapping to find the correct C lib name for the # encoding. #
Example #28
Source File: locale.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding, norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = locale_encoding_alias.get(norm_encoding, norm_encoding) #print('found encoding %r' % encoding) return langname + '.' + encoding
Example #29
Source File: locale.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using, according to the system configuration.""" if do_setlocale: oldloc = setlocale(LC_CTYPE) try: setlocale(LC_CTYPE, "") except Error: pass result = nl_langinfo(CODESET) setlocale(LC_CTYPE, oldloc) return result else: return nl_langinfo(CODESET) ### Database # # The following data was extracted from the locale.alias file which # comes with X11 and then hand edited removing the explicit encoding # definitions and adding some more aliases. The file is usually # available as /usr/lib/X11/locale/locale.alias. # # # The local_encoding_alias table maps lowercase encoding alias names # to C locale encoding names (case-sensitive). Note that normalize() # first looks up the encoding in the encodings.aliases dictionary and # then applies this mapping to find the correct C lib name for the # encoding. #
Example #30
Source File: locale.py From unity-python with MIT License | 5 votes |
def _replace_encoding(code, encoding): if '.' in code: langname = code[:code.index('.')] else: langname = code # Convert the encoding to a C lib compatible encoding string norm_encoding = encodings.normalize_encoding(encoding) #print('norm encoding: %r' % norm_encoding) norm_encoding = encodings.aliases.aliases.get(norm_encoding, norm_encoding) #print('aliased encoding: %r' % norm_encoding) encoding = locale_encoding_alias.get(norm_encoding, norm_encoding) #print('found encoding %r' % encoding) return langname + '.' + encoding