By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,235 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,235 IT Pros & Developers. It's quick & easy.

Re: b64encode and unicode problem

P: n/a
Gabriel Rossetti skrev:
Hello everyone,

I am trying to encode a string using b4encode and I get the following
error :
>>b64encode(u"Salut Pierre, comment ça va?")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/", line 53, in b64encode
encoded = binascii.b2a_base64(s)[:-1]
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' in
position 22: ordinal not in range(128)

If I remove the "u" infront of the string, it works. The problem is that
I in my program, the string is given to me un unicode/utf-8. I tried
several things, but I still get it, How can I get it to work, anybody
have any idea?
I have written about it here:

The reason/solution for your problem is mentioned somewhere below the

hilsen/regards Max M, Denmark
IT's Mad Science

Jun 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.