• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python sys.getfilesystemencoding函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sys.getfilesystemencoding函数的典型用法代码示例。如果您正苦于以下问题:Python getfilesystemencoding函数的具体用法?Python getfilesystemencoding怎么用?Python getfilesystemencoding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getfilesystemencoding函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: expanduser_unicode

def expanduser_unicode(s):
    # expanduser() doesn't handle non-ascii characters in environment variables
    # https://gna.org/bugs/index.php?17111
    s = s.encode(sys.getfilesystemencoding())
    s = os.path.expanduser(s)
    s = s.decode(sys.getfilesystemencoding())
    return s
开发者ID:alcemirfernandes,项目名称:mypaint,代码行数:7,代码来源:fileutils.py


示例2: _get_build_extension

    def _get_build_extension(self, extension=None, lib_dir=None, temp_dir=None,
                             pgo_step_name=None, _build_ext=build_ext):
        self._clear_distutils_mkpath_cache()
        dist = Distribution()
        config_files = dist.find_config_files()
        try:
            config_files.remove('setup.cfg')
        except ValueError:
            pass
        dist.parse_config_files(config_files)

        if not temp_dir:
            temp_dir = lib_dir
        add_pgo_flags = self._add_pgo_flags

        if pgo_step_name:
            base_build_ext = _build_ext
            class _build_ext(_build_ext):
                def build_extensions(self):
                    add_pgo_flags(self, pgo_step_name, temp_dir)
                    base_build_ext.build_extensions(self)

        build_extension = _build_ext(dist)
        build_extension.finalize_options()
        if temp_dir:
            temp_dir = py3compat.cast_bytes_py2(temp_dir, encoding=sys.getfilesystemencoding())
            build_extension.build_temp = temp_dir
        if lib_dir:
            lib_dir = py3compat.cast_bytes_py2(lib_dir, encoding=sys.getfilesystemencoding())
            build_extension.build_lib = lib_dir
        if extension is not None:
            build_extension.extensions = [extension]
        return build_extension
开发者ID:cython,项目名称:cython,代码行数:33,代码来源:IpythonMagic.py


示例3: getKindleInfoFiles

def getKindleInfoFiles(kInfoFiles):
    # first search for current .kindle-info files
    home = os.getenv('HOME')
    cmdline = 'find "' + home + '/Library/Application Support" -name ".kindle-info"'
    cmdline = cmdline.encode(sys.getfilesystemencoding())
    p1 = subprocess.Popen(cmdline, shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False)
    out1, out2 = p1.communicate()
    reslst = out1.split('\n')
    kinfopath = 'NONE'
    found = False
    for resline in reslst:
        if os.path.isfile(resline):
            kInfoFiles.append(resline)
            found = True
    # add any .kinf files 
    cmdline = 'find "' + home + '/Library/Application Support" -name ".rainier*-kinf"'
    cmdline = cmdline.encode(sys.getfilesystemencoding())
    p1 = subprocess.Popen(cmdline, shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False)
    out1, out2 = p1.communicate()
    reslst = out1.split('\n')
    for resline in reslst:
        if os.path.isfile(resline):
            kInfoFiles.append(resline)
            found = True
    if not found:
        print('No kindle-info files have been found.')
    return kInfoFiles
开发者ID:RudiKe,项目名称:bin,代码行数:27,代码来源:k4mutils.py


示例4: _make_path

def _make_path(ent):
    if isinstance(ent, Entry):
        ent = ent.ftsent
    if ent.fts_path:
        return ffi.string(ent.fts_path).decode(sys.getfilesystemencoding())
    else:
        return ffi.string(ent.fts_name).decode(sys.getfilesystemencoding())
开发者ID:abarnert,项目名称:scandir,代码行数:7,代码来源:fts.py


示例5: _main

def _main(argv):
    import optparse

    usage = "usage: %prog [options] <file1 file2 ...>\n<stdin> will be used as input source if no file specified."
    
    parser = optparse.OptionParser(usage=usage, version="%%prog %s @ Copyright %s" % (__version__, __copyright__))
    parser.add_option('-t', '--target-language', metavar='zh-CN',
                      help='specify target language to translate the source text into')
    parser.add_option('-s', '--source-language', default='', metavar='en',
                      help='specify source language, if not provide it will identify the source language automatically')
    parser.add_option('-i', '--input-encoding', default=sys.getfilesystemencoding(), metavar='utf-8',
                      help='specify input encoding, default to current console system encoding')
    parser.add_option('-o', '--output-encoding', default=sys.getfilesystemencoding(), metavar='utf-8',
                      help='specify output encoding, default to current console system encoding')

    options, args = parser.parse_args(argv[1:])
    
    if not options.target_language:
        print('Error: missing target language!')
        parser.print_help()
        return
    
    gs = Goslate()
    import fileinput
    # inputs = fileinput.input(args, mode='rU', openhook=fileinput.hook_encoded(options.input_encoding))
    inputs = fileinput.input(args, mode='rb')
    inputs = (i.decode(options.input_encoding) for i in inputs)
    outputs = gs.translate(inputs, options.target_language, options.source_language)
    for i in outputs:
        sys.stdout.write((i+u'\n').encode(options.output_encoding))
        sys.stdout.flush()
开发者ID:Abdillah,项目名称:LiSpeak,代码行数:31,代码来源:goslate.py


示例6: packValue

def packValue(valueType, value):
    if valueType == REG_DWORD:
        retData = pack('<L', value)
    elif valueType == REG_DWORD_BIG_ENDIAN:
        retData = pack('>L', value)
    elif valueType == REG_EXPAND_SZ:
        try:
            retData = value.encode('utf-16le')
        except UnicodeDecodeError:
            import sys
            retData = value.decode(sys.getfilesystemencoding()).encode('utf-16le')
    elif valueType == REG_MULTI_SZ:
        try:
            retData = value.encode('utf-16le')
        except UnicodeDecodeError:
            import sys
            retData = value.decode(sys.getfilesystemencoding()).encode('utf-16le')
    elif valueType == REG_QWORD:
        retData = pack('<Q', value)
    elif valueType == REG_QWORD_LITTLE_ENDIAN:
        retData = pack('>Q', value)
    elif valueType == REG_SZ:
        try:
            retData = value.encode('utf-16le')
        except UnicodeDecodeError:
            import sys
            retData = value.decode(sys.getfilesystemencoding()).encode('utf-16le')
    else:
        retData = value

    return retData
开发者ID:skelsec,项目名称:impacket,代码行数:31,代码来源:rrp.py


示例7: expanduser_unicode

def expanduser_unicode(s):
    """Expands a ~/ on the front of a unicode path, where meaningful.

    :param s: path to expand, coercable to unicode
    :returns: The expanded path
    :rtype: unicode

    This doesn't do anything on the Windows platform other than coerce
    its argument to unicode. On other platforms, it converts a "~"
    component on the front of a relative path to the user's absolute
    home, like os.expanduser().

    Certain workarounds for OS and filesystem encoding issues are
    implemented here too.

    """
    s = unicode(s)
    # The sys.getfilesystemencoding() on Win32 (mbcs) is for encode
    # only, and isn't roundtrippable. Luckily ~ is not meaningful on
    # Windows, and MyPaint uses a better default for the scrap prefix on
    # the Windows platform anyway.
    if sys.platform == "win32":
        return s
    # expanduser() doesn't handle non-ascii characters in environment variables
    # https://gna.org/bugs/index.php?17111
    s = s.encode(sys.getfilesystemencoding())
    s = os.path.expanduser(s)
    s = s.decode(sys.getfilesystemencoding())
    return s
开发者ID:iisupreme,项目名称:mypaint,代码行数:29,代码来源:fileutils.py


示例8: stage

    def stage(self, fs_paths):
        """Stage a set of paths.

        :param fs_paths: List of paths, relative to the repository path
        """

        root_path_bytes = self.path.encode(sys.getfilesystemencoding())

        if not isinstance(fs_paths, list):
            fs_paths = [fs_paths]
        from dulwich.index import (
            blob_from_path_and_stat,
            index_entry_from_stat,
            _fs_to_tree_path,
            )
        index = self.open_index()
        for fs_path in fs_paths:
            if not isinstance(fs_path, bytes):
                fs_path = fs_path.encode(sys.getfilesystemencoding())
            tree_path = _fs_to_tree_path(fs_path)
            full_path = os.path.join(root_path_bytes, fs_path)
            try:
                st = os.lstat(full_path)
            except OSError:
                # File no longer exists
                try:
                    del index[tree_path]
                except KeyError:
                    pass  # already removed
            else:
                blob = blob_from_path_and_stat(full_path, st)
                self.object_store.add_object(blob)
                index[tree_path] = index_entry_from_stat(st, blob.id, 0)
        index.write()
开发者ID:akbargumbira,项目名称:qgis_resources_sharing,代码行数:34,代码来源:repo.py


示例9: write_fileobj

    def write_fileobj(self, file_obj):
        """Write the coverage data to `file_obj`."""

        # Create the file data.
        file_data = {}

        if self._has_arcs():
            file_data['arcs'] = dict(
                (fname.decode(sys.getfilesystemencoding()),
                    [tuple(pair) for pair in self._arcs])
                for fname, arcs in iitems(data['arcs'])
            )

        if self._has_lines():
            file_data['lines'] = dict(
                (fname.decode(sys.getfilesystemencoding()), linenos)
                for fname, linenos in iitems(self._lines)
            )

        if self._file_tracers:
            file_data['file_tracers'] = self._file_tracers

        if self._runs:
            file_data['runs'] = self._runs

        # Write the data to the file.
        file_obj.write(self._GO_AWAY)
        json.dump(file_data, file_obj)
开发者ID:pycom,项目名称:EricShort,代码行数:28,代码来源:data.py


示例10: read_fileobj

    def read_fileobj(self, file_obj):
        """Read the coverage data from the given file object.

        Should only be used on an empty CoverageData object.

        """
        data = self._read_raw_data(file_obj)

        self._lines = self._arcs = None

        if 'lines' in data:
            self._lines = dict(
                (fname.encode(sys.getfilesystemencoding()), linenos)
                for fname, linenos in iitems(data['lines'])
            )

        if 'arcs' in data:
            self._arcs = dict(
                (fname.encode(sys.getfilesystemencoding()),
                    [tuple(pair) for pair in arcs])
                for fname, arcs in iitems(data['arcs'])
            )
        self._file_tracers = data.get('file_tracers', {})
        self._runs = data.get('runs', [])

        self._validate()
开发者ID:pycom,项目名称:EricShort,代码行数:26,代码来源:data.py


示例11: refresh_cb

 def refresh_cb(self, *args):
     self.popup_menu.popdown()
     mm = Gtk.Menu()
     oo = Gtk.Menu()
     for i in os.listdir(mount_prefix):
         mp = os.path.join(mount_prefix,i)
         if (os.path.ismount(mp)): 
             j = Gtk.MenuItem(i.decode(sys.getfilesystemencoding())) 
             o = Gtk.MenuItem(i.decode(sys.getfilesystemencoding())) 
             j.connect('activate', self.umount_cb, i)
             o.connect('activate', lambda a: run_file_man(mp))
             mm.add(j)
             oo.add(o) 
         mm.add(Gtk.SeparatorMenuItem())
         oo.add(Gtk.SeparatorMenuItem())
     i = Gtk.ImageMenuItem(Gtk.STOCK_REFRESH)
     i.connect('activate', self.refresh_cb)
     mm.add(i)
     i = Gtk.ImageMenuItem(Gtk.STOCK_REFRESH)
     i.connect('activate', self.refresh_cb)
     oo.add(i)
     mounted_menu = mm
     open_menu = oo
     g = self.open_menu_item.get_submenu()
     s = self.umount_menu_item.get_submenu()
     self.umount_menu_item.set_submenu(mm)
     self.open_menu_item.set_submenu(oo)
     del s, g
开发者ID:ojuba-org,项目名称:ojuba-virtual-cd,代码行数:28,代码来源:OjubaVirtualCD.py


示例12: pack

	def pack(self, dst, src, src_path):
		chrome_path = self.get_chrome_path()
		if chrome_path is not None:
			extension_path = os.path.abspath(src)
			certificate_path = os.path.abspath(os.path.join(extension_path, '../', '../', 'certificates'))
			if not os.path.exists(certificate_path):
				os.makedirs(certificate_path)
			certificate_path = os.path.join(certificate_path, 'chrome.pem')

			cmd = chrome_path + ' --pack-extension="' + extension_path + '"'
			if os.path.isfile(certificate_path):
				cmd += ' --pack-extension-key="' + certificate_path + '"'
			cmd += ' --no-message-box'
			os.system(cmd.encode(sys.getfilesystemencoding()))

			extension_dst = os.path.abspath(os.path.join(extension_path, '../', 'chrome.crx'))
			if not os.path.isfile(extension_dst):
				cmd = '"' + chrome_path + '"' + ' --pack-extension="' + extension_path + '"'
				if os.path.isfile(certificate_path):
					cmd += ' --pack-extension-key="' + certificate_path + '"'
				cmd += ' --no-message-box'
				subprocess.call(cmd.encode(sys.getfilesystemencoding()))
			try:
				shutil.move(os.path.abspath(os.path.join(extension_path, '../', 'chrome.pem')), certificate_path)
			except:
				pass
			shutil.move(extension_dst, os.path.join(dst, self.get_full_package_name(self._info)))
		else:
			kango.log('Chrome/Chromium is not installed, can\'t pack chrome extension.')
开发者ID:cherepanov,项目名称:teabasket,代码行数:29,代码来源:chrome.py


示例13: execute

    def execute(self, content):
        command = self.get_link_command()
        if not command:
            sublime.error_message("Could not get link opener command.\nPlatform not yet supported.")
            return None

        content = content.encode(sys.getfilesystemencoding())
        cmd = command + [content]
        arg_list_wrapper = self.settings.get("orgmode.open_link.resolver.abstract.arg_list_wrapper", [])
        if arg_list_wrapper:  # NOTE never use shell=True below.
            cmd = arg_list_wrapper + [" ".join(cmd)]
            source_filename = '"' + self.view.file_name() + '"'
            cmd += [source_filename]
            # TODO: hack here (outcommented)
            # cmd += ['--origin', source_filename, '--quiet']
        print "*****"
        print repr(content), content
        print repr(cmd)
        print cmd
        sublime.status_message("Executing: %s" % cmd)
        process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)

        stdout, stderr = process.communicate()
        if stdout:
            stdout = unicode(stdout, sys.getfilesystemencoding())
            sublime.status_message(stdout)
        if stderr:
            stderr = unicode(stderr, sys.getfilesystemencoding())
            sublime.error_message(stderr)
开发者ID:BBBSnowball,项目名称:orgmode,代码行数:29,代码来源:abstract.py


示例14: main

def main():
    args = sys.argv
    cur_sys = system()
    file_name = GLOBALS["db_name"]+"-"+str(options.port)+".log"
    # if cur_sys == "Darwin":
    #     f = "/Users/"+os.getlogin()+"/Desktop/"+ file_name
    # elif cur_sys == "Linux":
    #     f = os.getcwd() + "/" + file_name
    # else:
    #     raise NotImplementedError
    # args.append("--log_file_prefix=" + f)
    # logging.basicConfig(filename=f, level=logging.DEBUG)

    tornado.options.parse_command_line()
    applicaton = Application()
    http_server = tornado.httpserver.HTTPServer(applicaton, xheaders=True)

    http_server.listen(options.port)
    print("="*50)
    print("initializing program with port : ", options.port)
    print("="*50)
    print("my ip is : ", socket.gethostbyname(socket.gethostname()))
    print("="*50)
    print("File system DEFAULT Encoding-type is : ", sys.getdefaultencoding())
    print("File system Encoding-type is : ", sys.getfilesystemencoding())
    print("="*50)
    logging.info("File system DEFAULT Encoding-type is : " + str(sys.getdefaultencoding()))
    logging.info("File system Encoding-type is : " +  str(sys.getfilesystemencoding()))

    ioloop = tornado.ioloop.IOLoop.instance()
    ioloop.start()
开发者ID:csyouk,项目名称:whereIsMyFriend,代码行数:31,代码来源:run.py


示例15: __init__

    def __init__(self, config, opts, args):
        """ :See: `wtf.services.ServiceInterface.__init__` """
        section = config.crash
        self._debug = bool(section('debug', False))
        if 'display' in section:
            fname, status = section.display.template, section.display.status
            fp = open(fname, 'rb')
            try:
                page = fp.read()
                mtime = _os.fstat(fp.fileno()).st_mtime
            finally:
                fp.close()
            self._display = page, status, fname, mtime
        if 'dump' in section:
            self._perms = int(section.dump('perms', '0644'), 8)
            self._dumpdir = _os.path.join(config.ROOT, unicode(
                section.dump.directory
            ).encode(_sys.getfilesystemencoding()))
            try:
                self._dumpdir_unicode = self._dumpdir.decode(
                    _sys.getfilesystemencoding()
                )
            except UnicodeError:
                self._dumpdir_unicode = self._dumpdir.decode('latin-1')

            # check write access
            fp, name = self._make_dumpfile()
            try:
                fp.write("!")
            finally:
                try:
                    fp.close()
                finally:
                    _os.unlink(name)
开发者ID:ndparker,项目名称:wtf,代码行数:34,代码来源:crash.py


示例16: home

def home():
	if name == 'nt':
		return unicode(environ['USERPROFILE'], getfilesystemencoding())
	elif platform == "darwin":	
		return unicode(environ['HOME'], getfilesystemencoding())
	else:
		return unicode(environ['HOME'], getfilesystemencoding())
开发者ID:jbreizh,项目名称:actimaths,代码行数:7,代码来源:values.py


示例17: encode_filename

def encode_filename(filename, from_encoding='utf-8', to_encoding=None):
    """
    >>> print encode_filename('\xe4\xb8\xad\xe5\x9b\xbd.doc')
    \xd6\xd0\xb9\xfa.doc
    >>> f = unicode('\xe4\xb8\xad\xe5\x9b\xbd.doc', 'utf-8')
    >>> print encode_filename(f)
    \xd6\xd0\xb9\xfa.doc
    >>> print encode_filename(f.encode('gbk'), 'gbk')
    \xd6\xd0\xb9\xfa.doc
    >>> print encode_filename(f, 'gbk', 'utf-8')
    \xe4\xb8\xad\xe5\x9b\xbd.doc
    >>> print encode_filename('\xe4\xb8\xad\xe5\x9b\xbd.doc', 'utf-8', 'gbk')
    \xd6\xd0\xb9\xfa.doc
    
    """
    import sys
    to_encoding = to_encoding or sys.getfilesystemencoding()
    from_encoding = from_encoding or sys.getfilesystemencoding()
    if not isinstance(filename, unicode):
        try:
            f = unicode(filename, from_encoding)
        except UnicodeDecodeError:
            try:
                f = unicode(filename, 'utf-8')
            except UnicodeDecodeError:
                raise Exception, "Unknown encoding of the filename %s" % filename
        filename = f
    if to_encoding:
        return filename.encode(to_encoding)
    else:
        return filename
开发者ID:08haozi,项目名称:uliweb,代码行数:31,代码来源:files.py


示例18: _setup_unix

    def _setup_unix(self, bind, basedir=None):
        """
        Setup UNIX domain socket 

        :Parameters:
         - `bind`: Bind parameter accessor (``match.group``)
         - `basedir`: Basedir for relative paths

        :Types:
         - `bind`: ``callable``
         - `basedir`: ``str``
        """
        if _AF_UNIX is None:
            raise ConfigurationError("UNIX domain sockets are not available")

        obind = repr(bind(0))
        if bind(u'perm'):
            try:
                socket_perm = int(bind('perm'), 8)
            except (TypeError, ValueError):
                raise ConfigurationError("Invalid permission")
            umask = 0777 & ~socket_perm
        else:
            umask = None
        basedir = basedir or _os.getcwd()
        if not isinstance(basedir, unicode):
            basedir = basedir.decode(_sys.getfilesystemencoding())
        path = _os.path.normpath(_os.path.join(
            basedir, bind(u'path')
        )).encode(_sys.getfilesystemencoding())
        socket = _socket.socket(_AF_UNIX, _socket.SOCK_STREAM)
        self._sockets.append(UnixSocket(socket, obind, path, umask))
开发者ID:wontfix-org,项目名称:wtf,代码行数:32,代码来源:listener.py


示例19: _run

    def _run(cmds):
        #~ print cmds
        cmdline = str( [" ".join(cmds)] ) # to output easily (with strange chars)
        try:
            cmds = [i.encode(sys.getfilesystemencoding()) for i in cmds]
        except:
            raise CommandException( cmdline +"\n encoding trouble")

        p = Popen(cmds, shell=False,stdout=PIPE,stderr=PIPE)
        time.sleep(0.01)    # to avoid "IOError: [Errno 4] Interrupted system call"
        out = string.join(p.stdout.readlines() ).strip()
        outerr = string.join(p.stderr.readlines() ).strip()

        if "exiftran" in cmdline:
            if "processing" in outerr:
                # exiftran output process in stderr ;-(
                outerr=""

        if outerr:
            raise CommandException( cmdline +"\n OUTPUT ERROR:"+outerr)
        else:
            try:
                out = out.decode("utf_8") # recupere les infos en UTF_8
            except:
                try:
                    out = out.decode("latin_1")  # recupere les anciens infos (en latin_1)
                except UnicodeDecodeError:
                    try:
                        out = out.decode(sys.getfilesystemencoding())
                    except UnicodeDecodeError:
                        raise CommandException( cmdline +"\n decoding trouble")

            return out #unicode
开发者ID:zy-sunshine,项目名称:pygtk-example,代码行数:33,代码来源:tools.py


示例20: encodeASCII

def encodeASCII(string, language=None): #from Unicodize and plex scanner and other sources
  if string=="": return ""
  ranges = [ {"from": ord(u"\u3300"), "to": ord(u"\u33ff")}, {"from": ord(u"\ufe30"), "to": ord(u"\ufe4f")}, {"from": ord(u"\uf900"), "to": ord(u"\ufaff")},  # compatibility ideographs
             {"from": ord(u"\u30a0"), "to": ord(u"\u30ff")}, {"from": ord(u"\u2e80"), "to": ord(u"\u2eff")},                                                  # Japanese Kana    # cjk radicals supplement
             {"from": ord(u"\u4e00"), "to": ord(u"\u9fff")}, {"from": ord(u"\u3400"), "to": ord(u"\u4dbf")}]                                                  # windows: TypeError: ord() expected a character, but string of length 2 found #{"from": ord(u"\U00020000"), "to": ord(u"\U0002a6df")}, #{"from": ord(u"\U0002a700"), "to": ord(u"\U0002b73f")}, #{"from": ord(u"\U0002b740"), "to": ord(u"\U0002b81f")}, #{"from": ord(u"\U0002b820"), "to": ord(u"\U0002ceaf")}, # included as of Unicode 8.0                             #{"from": ord(u"\U0002F800"), "to": ord(u"\U0002fa1f")}  # compatibility ideographs
  encodings, encoding = ['iso8859-1', 'utf-16', 'utf-16be', 'utf-8'], ord(string[0])                                                                          #
  if 0 <= encoding < len(encodings):  string = string[1:].decode('cp949') if encoding == 0 and language == 'ko' else string[1:].decode(encodings[encoding])   # If we're dealing with a particular language, we might want to try another code page.
  if sys.getdefaultencoding() not in encodings:
    try:     string = string.decode(sys.getdefaultencoding())
    except:  pass
  if not sys.getfilesystemencoding()==sys.getdefaultencoding():
    try:     string = string.decode(sys.getfilesystemencoding())
    except:  pass
  string = string.strip('\0')
  try:       string = unicodedata.normalize('NFKD', string)    # Unicode  to ascii conversion to corect most characters automatically
  except:    pass
  try:       string = re.sub(RE_UNICODE_CONTROL, '', string)   # Strip control characters.
  except:    pass
  try:       string = string.encode('ascii', 'replace')        # Encode into Ascii
  except:    pass
  original_string, string, i = string, list(string), 0
  while i < len(string):                                       ### loop through unicode and replace special chars with spaces then map if found ###
    if ord(string[i])<128:  i = i+1
    else: #non ascii char
      char, char2, char3, char_len = 0, "", [], unicodeLen(string[i])
      for x in range(0, char_len):
        char = 256*char + ord(string[i+x]); char2 += string[i+x]; char3.append(string[i+x])
        if not x==0: string[i] += string[i+x]; string[i+x]=''
      try:    asian_language = any([mapping["from"] <= ord("".join(char3).decode('utf8')) <= mapping["to"] for mapping in ranges])
      except: asian_language = False
      if char in CHARACTERS_MAP:  string[i]=CHARACTERS_MAP.get( char )
      elif not asian_language:    Log("*Character missing in CHARACTERS_MAP: %d:'%s'  , #'%s' %s, string: '%s'" % (char, char2, char2, char3, original_string))
      i += char_len
  return ''.join(string)
开发者ID:glowingwire,项目名称:Absolute-Series-Scanner,代码行数:34,代码来源:Absolute+Series+Scanner+-+Alpha.py



注:本文中的sys.getfilesystemencoding函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sys.getprofile函数代码示例发布时间:2022-05-27
下一篇:
Python sys.getdlopenflags函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap