mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	 69652035bc
			
		
	
	
		69652035bc
		
	
	
	
	
		
			
			decoding incomplete input (when the input stream is temporarily exhausted). codecs.StreamReader now implements buffering, which enables proper readline support for the UTF-16 decoders. codecs.StreamReader.read() has a new argument chars which specifies the number of characters to return. codecs.StreamReader.readline() and codecs.StreamReader.readlines() have a new argument keepends. Trailing "\n"s will be stripped from the lines if keepends is false. Added C APIs PyUnicode_DecodeUTF8Stateful and PyUnicode_DecodeUTF16Stateful.
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			535 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			535 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| """ Python 'utf-8' Codec
 | |
| 
 | |
| 
 | |
| Written by Marc-Andre Lemburg (mal@lemburg.com).
 | |
| 
 | |
| (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
 | |
| 
 | |
| """
 | |
| import codecs
 | |
| 
 | |
| ### Codec APIs
 | |
| 
 | |
| encode = codecs.utf_8_encode
 | |
| 
 | |
| def decode(input, errors='strict'):
 | |
|     return codecs.utf_8_decode(input, errors, True)
 | |
| 
 | |
| class StreamWriter(codecs.StreamWriter):
 | |
|     encode = codecs.utf_8_encode
 | |
| 
 | |
| class StreamReader(codecs.StreamReader):
 | |
|     decode = codecs.utf_8_decode
 | |
| 
 | |
| ### encodings module API
 | |
| 
 | |
| def getregentry():
 | |
| 
 | |
|     return (encode,decode,StreamReader,StreamWriter)
 |