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) (where task.subject was previously assigned the value of task.Subject, aka the Subject property of an Outlook 2010 TaskItem) >From what I understand from reading online, the error is telling me that the subject line contains an en dash and that Python is trying to convert to ascii and failing (as it should). Here's where I'm getting stuck. In the code above I was just printing the subject so I can see whether the script is working properly. Ultimately what I want to do is parse the tasks I'm interested in and then create an HTML file containing those tasks. Given that, what's the best way to fix this problem? BTW, if there's a clear description of the best solution for this particular problem – i.e., where I want to ultimately display the results as HTML – please feel free to refer me to the link. I tried reading a number of docs on the web but still feel pretty lost. Thanks, Anders -- http://mail.python.org/mailman/listinfo/python-list