UnicodeEncodeError - a bit out of my element...

kyosohma at gmail.com kyosohma at gmail.com
Wed Apr 11 17:55:19 CEST 2007

On Apr 11, 10:16 am, "erikcw" <erikwickst... at gmail.com> wrote:
> Hi all,
> I'm trying to parse an email message, but am running into this
> exception.
> Traceback (most recent call last):
>   File "wa.py", line 336, in ?
>     main()
>   File "wa.py", line 332, in main
>     print out['msg']
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xd6' in
> position 238: ordinal not in range(128)
> How can I decode/encode this string to print to stdout and send again
> in another email?  Do I have to know what language the email is in?
> Thanks!
> Erik

You'll need to do some encoding/decoding work. Check out the following
links on unicode:


And here's a few links on parsing:


Probably more information than you need, but it should help answer
your question (and maybe any future questions about Unicode).


More information about the Python-list mailing list