mirror of
				https://gitlab.com/ytdl-org/youtube-dl.git
				synced 2025-11-03 23:57:06 -05:00 
			
		
		
		
	Simplified preferredencoding()
Not sure what is the point to use yield to return encoding, thus it will simplify the whole function. Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
This commit is contained in:
		@@ -32,15 +32,13 @@ def preferredencoding():
 | 
			
		||||
	Returns the best encoding scheme for the system, based on
 | 
			
		||||
	locale.getpreferredencoding() and some further tweaks.
 | 
			
		||||
	"""
 | 
			
		||||
	def yield_preferredencoding():
 | 
			
		||||
		try:
 | 
			
		||||
			pref = locale.getpreferredencoding()
 | 
			
		||||
			u'TEST'.encode(pref)
 | 
			
		||||
		except:
 | 
			
		||||
			pref = 'UTF-8'
 | 
			
		||||
		while True:
 | 
			
		||||
			yield pref
 | 
			
		||||
	return yield_preferredencoding().next()
 | 
			
		||||
	try:
 | 
			
		||||
		pref = locale.getpreferredencoding()
 | 
			
		||||
		u'TEST'.encode(pref)
 | 
			
		||||
	except:
 | 
			
		||||
		pref = 'UTF-8'
 | 
			
		||||
 | 
			
		||||
	return pref
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def htmlentity_transform(matchobj):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user