示例#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
 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
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
 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
 def getpreferredencoding(do_setlocale=True):
     """Return the charset that the user is likely using."""
     import _bootlocale
     return _bootlocale.getpreferredencoding(False)