You Are Here:

Community: Developer Discussion Boards

#1 Old file.write => UnicodeError - 2006-03-02, 21:30

Join Date: Oct 2004
Posts: 158
bercobeute
Offline
Regular Contributor
I'm trying to write text from a TextComponent to a file, but that gives me the following error:

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


How can I solve this?
Reply With Quote

#2 Old Re: file.write => UnicodeError - 2006-03-03, 08:46

Join Date: Aug 2004
Posts: 290
simo.salminen
Offline
Regular Contributor
write:
fh.write(your_unicode_string.encode("utf-8"))

read:
unicode_string = fh.read().decode("utf-8")

Also, check this: http://www.joelonsoftware.com/articles/Unicode.html "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)"
Reply With Quote

#3 Old Re: file.write => UnicodeError - 2006-03-03, 11:04

Join Date: Oct 2004
Posts: 158
bercobeute
Offline
Regular Contributor
Thanks for the help and the excellent link! It definitely made things a lot clearer for me. Indeed a 'must read' for all software developers.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Recording in Amr Format losym Symbian Media (Graphics & Sounds) 12 2009-03-26 07:41
RecvFrom => KErrGeneral in an endless loop glr Symbian Networking & Messaging 3 2006-08-29 11:49
GPRS + Camera => Losing Network Coverage 3david Python 4 2005-08-23 13:46
reading 5 minutes => IO.Exception ooooooo Mobile Java General 9 2004-08-08 08:10

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia