[UnicodeEncodeError] Don't know what else to try

Gilles Ganault nospam at nospam.com
Sat Nov 15 14:12:42 CET 2008


On Fri, 14 Nov 2008 17:39:00 +0100, "Martin v. Löwis"
<martin at v.loewis.de> wrote:
>Can you first please report what happened when you add the print statement?

Thanks guys, I found how to handle this:

===========
for id in rows:
	#Says Unicode, but it's actually not
	#print type(id[1])
	#<type 'unicode'>

	try:
		print id[1];
	except UnicodeEncodeError:
		print "Not unicode"
		try:
			print id[1].encode('iso8859-15')
			print "iso"
		except UnicodeEncodeError:
			print id[1].encode('cp1252')
			print "Windows"
===========

Thank you.



More information about the Python-list mailing list