Ordinal not in range(128)

Fabien HENON fabien.henon at caramail.com
Sat Mar 1 20:12:07 EST 2003


I have written a POV-RAY editor for Linux using Python and Tkinter.
It mostly uses the text widget of Tkinter.

You can find it at :
http://pyvon.sourceforge.net

As you can add comments in POV-RAY scripts, people who are using 
extended character (é,à,...) get the following message :

UnicodeError: ASCII encoding error: ordinal not in range(128)


Here is the code that writes what is inside the text widget to a file.

#-------------------- snip ---------------------------
def save(event=None):
	global filename
	global scene_idx
         scene_contents = text.get(1.0, END)
         if scene_contents:
		try:
	                fd = open(General_Buffer[scene_idx][0], 'w')
	                for line in string.split(scene_contents, '\n'):
	                    fd.write(line)
			    fd.write('\n')
	                fd.close
		except:
			write_permissions()

#---------------- snap ---------------------------------


How can I work that problem around ?

Thanks,

Fabien HENON





More information about the Python-list mailing list