You Are Here:

Community: Developer Discussion Boards

#1 Old Question File name and codecs - 2008-08-20, 16:57

Join Date: Nov 2006
Posts: 17
oper6600
Offline
Registered User
Hi,

name=u'papà' #Character accented à
f = open(name,"w")


and the application ends with error:

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

Do you have a solution?
Reply With Quote

#2 Old Re: File name and codecs - 2008-08-20, 17:07

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Online
Forum Nokia Champion
Quote:
Originally Posted by oper6600 View Post
Hi,

name=u'papà' #Character accented à
f = open(name,"w")


and the application ends with error:

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

Do you have a solution?
hi
what you are opening???
if you are opening a file you have to open it with a proper extension and mode that may solve ur problem.


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#3 Old Re: File name and codecs - 2008-08-20, 17:10

Join Date: Nov 2006
Posts: 186
Location: Pune, india
sagars's Avatar
sagars
Offline
Regular Contributor
you can take some help from following linklink

give complete path of file to be opened.
Reply With Quote

#4 Old Re: File name and codecs - 2008-08-21, 08:11

Join Date: Nov 2006
Posts: 17
oper6600
Offline
Registered User
name=u'e:\\system\\apps\\application_name\\papà.txt'

the solution is:

sys.setdefaultencoding('iso-8859-1')
f=open(name,'w')
...


Tanks for reply.
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

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