On Wed, 07 Nov 2012 14:17:42 -0800, Anders wrote:

> I've run into a Unicode error, and despite doing some googling, I can't
> figure out the right way to fix it. I have a Python 2.6 script that
> reads my Outlook 2010 task list. I'm able to read the tasks from Outlook
> and store them as a list of objects without a hitch.  But when I try to
> print the tasks' subjects, one of the tasks is generating an error:
> 
> Traceback (most recent call last):
>   File "outlook_tasks.py", line 66, in <module>
>     my_tasks.dump_today_tasks()
>   File "C:\Users\Anders\code\Task List\tasks.py", line 29, in
> dump_today_tasks
>     print task.subject
> UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in
> position 42: ordinal not in range(128)


This error confuses me. Is that an exact copy and paste of the error, or 
have you edited it or reconstructed it? Because it seems to me that if 
task.subject is a unicode string, as it appears to be, calling print on 
it should succeed:

py> s = u'ABC\u2013DEF'
py> print s
ABC–DEF

What does type(task.subject) return?


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to