Ticket #14777: csv-unicode.diff

File csv-unicode.diff, 1.1 KB (added by Adam Vandenberg, 14 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.
    5858
     59Handling Unicode
     60~~~~~~~~~~~~~~~~
     61
     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.
     65
     66    * Manually encode all Unicode objects before saving. This is, obviously,
     67      a hassle and error-prone.
     68
     69    * Use the ``UnicodeWriter`` provided in the `csv module's examples section`_.
     70
     71    * Use the `python-unicodecsv module`_, which aims to be a drop-in
     72      replacement for ``csv`` that does gracefully handle Unicode.
     73
     74.. _`csv module's examples section`: http://docs.python.org/library/csv.html#examples
     75.. _`python-unicodecsv module`: https://github.com/jdunck/python-unicodecsv
     76
    5977Using the template system
    6078=========================
    6179
Back to Top