Ticket #14777: csv-unicode.diff

File csv-unicode.diff, 1.1 KB (added by Adam Vandenberg, 7 years ago)

Initial patch

  • docs/howto/outputting-csv.txt

    diff --git a/docs/howto/outputting-csv.txt b/docs/howto/outputting-csv.txt
    index 169114f..b406a27 100644
    a b mention: 
    5656      about escaping strings with quotes or commas in them. Just pass
    5757      ``writerow()`` your raw strings, and it'll do the right thing.
     59Handling Unicode
     62Python's ``csv`` module expects to be passed strings, not Unicode objects, but
     63strings read from ``HttpRequest`` and databases in Django will typically be
     64Unicode. There are a few options for handling this.
     66    * Manually encode all Unicode objects before saving. This is, obviously,
     67      a hassle and error-prone.
     69    * Use the ``UnicodeWriter`` provided in the `csv module's examples section`_.
     71    * Use the `python-unicodecsv module`_, which aims to be a drop-in
     72      replacement for ``csv`` that does gracefully handle Unicode.
     74.. _`csv module's examples section`: http://docs.python.org/library/csv.html#examples
     75.. _`python-unicodecsv module`: https://github.com/jdunck/python-unicodecsv
    5977Using the template system
Back to Top