On Tue, Apr 14, 2009 at 12:35 PM, Alex Gaynor <alex.gay...@gmail.com> wrote:

> On Tue, Apr 14, 2009 at 12:25 PM, Jesse <adles...@gmail.com> wrote:
>
>>
>> The error is 'ascii' codec can't encode character u'\xb0' in position
>> 98: ordinal not in range(128) and it occurs when a temperature degree
>> such as 35°C
>> is in the text.
>>
>> I'm using the following code in the view.py:
>>
>>   response = HttpResponse(mimetype='text/csv')
>>    response['Content-Disposition'] = 'attachment;
>> filename=publication.csv'
>>    writer = csv.writer(response)
>>    writer.writerow(['Title', 'Authors', 'Year', 'Journal',
>> 'Citation', 'Web Address'])
>>    for publication in publication_list:
>>        writer.writerow([publication.pubtitlestrip,
>> publication.pubauthors, publication.year, publication.journal,
>> publication.pubcitationnum, publication.pubwebaddress])
>>    return response
>>
>> Is there someway to unicode the writer?
>>
>>
>>
>>
> Simon Willison(I think) wrote up a class that implements the same API but
> handles unicode: http://www.djangosnippets.org/snippets/993/
>

Note also this is really a pure Python question and has nothing to do with
Django.  Don't forget to consult the relevant docs for whatever code (in
this case csv) you happen to be using.

In this case the Python csv doc:

http://docs.python.org/library/csv.html

covers the issue pretty clearly (just search for unicode on the page), and
also includes an example of a writer class that supports writing Unicode.

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to