mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			34 lines
		
	
	
	
		
			762 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
	
		
			762 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| """ Python 'iconv' Codec
 | |
| 
 | |
| 
 | |
| Written by Hye-Shik Chang (perky@FreeBSD.org).
 | |
| 
 | |
| Copyright(c) Python Software Foundation, All Rights Reserved. NO WARRANTY.
 | |
| 
 | |
| """
 | |
| 
 | |
| import _iconv_codec
 | |
| import codecs
 | |
| 
 | |
| def lookup(enc):
 | |
|     class IconvCodec(_iconv_codec.iconvcodec, codecs.Codec):
 | |
|         encoding = enc
 | |
| 
 | |
|     try:
 | |
|         c = IconvCodec()
 | |
| 
 | |
|         class IconvStreamReader(IconvCodec, codecs.StreamReader):
 | |
|             __init__ = codecs.StreamReader.__init__
 | |
|         class IconvStreamWriter(IconvCodec, codecs.StreamWriter):
 | |
|             __init__ = codecs.StreamWriter.__init__
 | |
| 
 | |
|         return (
 | |
|             c.encode, c.decode,
 | |
|             IconvStreamReader, IconvStreamWriter
 | |
|         )
 | |
|     except ValueError:
 | |
|         return None
 | |
| 
 | |
| codecs.register(lookup)
 | |
| 
 | |
| # ex: ts=8 sts=4 et
 | 
