コード例 #1
0
 def _alias_mbcs(encoding):
     try:
         import _bootlocale
         if encoding == _bootlocale.getpreferredencoding(False):
             import encodings.mbcs
             return encodings.mbcs.getregentry()
     except ImportError:
         pass
コード例 #2
0
ファイル: __init__.py プロジェクト: Josquin95/Triqui
 def _alias_mbcs(encoding):
     try:
         import _bootlocale
         if encoding == _bootlocale.getpreferredencoding(False):
             import encodings.mbcs
             return encodings.mbcs.getregentry()
     except ImportError:
         # Imports may fail while we are shutting down
         pass
コード例 #3
0
 def _alias_mbcs(encoding):
     try:
         import _bootlocale
         if encoding == _bootlocale.getpreferredencoding(False):
             import encodings.mbcs
             return encodings.mbcs.getregentry()
     except ImportError:
         # Imports may fail while we are shutting down
         pass
コード例 #4
0
def aliasmbcs():
    """On Windows, some default encodings are not provided by Python,
    while they are always available as "mbcs" in each locale. Make
    them usable by aliasing to "mbcs" in such a case."""
    if sys.platform == 'win32':
        import _bootlocale, codecs
        enc = _bootlocale.getpreferredencoding(False)
        if enc.startswith('cp'):  # "cp***" ?
            try:
                codecs.lookup(enc)
            except LookupError:
                import encodings
                encodings._cache[enc] = encodings._unknown
                encodings.aliases.aliases[enc] = 'mbcs'
コード例 #5
0
ファイル: site.py プロジェクト: Cartmanfku/cpython
def aliasmbcs():
    """On Windows, some default encodings are not provided by Python,
    while they are always available as "mbcs" in each locale. Make
    them usable by aliasing to "mbcs" in such a case."""
    if sys.platform == 'win32':
        import _bootlocale, codecs
        enc = _bootlocale.getpreferredencoding(False)
        if enc.startswith('cp'):            # "cp***" ?
            try:
                codecs.lookup(enc)
            except LookupError:
                import encodings
                encodings._cache[enc] = encodings._unknown
                encodings.aliases.aliases[enc] = 'mbcs'
コード例 #6
0
ファイル: locale.py プロジェクト: emilyemorehouse/ast-and-me
 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
コード例 #7
0
def aliasmbcs():
    if sys.platform == 'win32':
        if sys.version_info < (3, 0):
            import locale, codecs
            enc = locale.getdefaultlocale()[1]
        else:
            import _bootlocale, codecs
            enc = _bootlocale.getpreferredencoding(False)
        if enc.startswith('cp'):
            try:
                codecs.lookup(enc)
            except LookupError:
                import encodings
                encodings._cache[enc] = encodings._unknown
                encodings.aliases.aliases[enc] = 'mbcs'
コード例 #8
0
ファイル: nodes.py プロジェクト: xxoolm/Ryven
 def update_event(self, inp=-1):
     self.set_output_val(0, _bootlocale.getpreferredencoding(self.input(0)))
コード例 #9
0
ファイル: locale.py プロジェクト: emilyemorehouse/ast-and-me
 def getpreferredencoding(do_setlocale=True):
     """Return the charset that the user is likely using."""
     import _bootlocale
     return _bootlocale.getpreferredencoding(False)