我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用encodings.search_function()。
def get_payload(self, index=None, decode=False): message = self.message if index is None: payload = message.get_payload(index, decode) if isinstance(payload, list): return [UMessage(msg) for msg in payload] if message.get_content_maintype() != 'text': return payload charset = message.get_content_charset() or 'iso-8859-1' if search_function(charset) is None: charset = 'iso-8859-1' return unicode(payload or '', charset, "replace") else: payload = UMessage(message.get_payload(index, decode)) return payload
def search_function(s): if s!="acodec": return None u8=encodings.search_function("utf8") return codecs.CodecInfo( name='acodec', encode=u8.encode, decode=u8.decode, incrementalencoder=u8.incrementalencoder, incrementaldecoder=u8.incrementaldecoder, streamreader=aStreamReader, # acodec StreamReader streamwriter=u8.streamwriter)
def search_function(encoding): if encoding != 'pyxl': return None # Assume utf8 encoding utf8=encodings.search_function('utf8') return codecs.CodecInfo( name = 'pyxl', encode = utf8.encode, decode = pyxl_decode, incrementalencoder = utf8.incrementalencoder, incrementaldecoder = PyxlIncrementalDecoder, streamreader = PyxlStreamReader, streamwriter = utf8.streamwriter)
def search_function(encoding): if encoding != 'pythonql': return None # Assume utf8 encoding utf8=encodings.search_function('utf8') return codecs.CodecInfo( name = 'pythonql', encode = utf8.encode, decode = pythonql_decode, incrementalencoder = utf8.incrementalencoder, incrementaldecoder = PythonqlIncrementalDecoder, streamreader = PythonqlStreamReader, streamwriter = utf8.streamwriter)