Commit 9195cc29 authored by Georg Brandl's avatar Georg Brandl

Bug #1440831: fix csv UnicodeWriter example

parent a87efd9d
...@@ -428,7 +428,7 @@ for row in csv.reader(['one,two,three']): ...@@ -428,7 +428,7 @@ for row in csv.reader(['one,two,three']):
The \module{csv} module doesn't directly support reading and writing The \module{csv} module doesn't directly support reading and writing
Unicode, but it is 8-bit clean save for some problems with \ASCII{} NUL Unicode, but it is 8-bit clean save for some problems with \ASCII{} NUL
characters, so you can write classes that handle the encoding and decoding characters, so you can write classes that handle the encoding and decoding
for you as long as you avoid encodings like utf-16 that use NULs. for you as long as you avoid encodings like utf-16 that use NULs:
\begin{verbatim} \begin{verbatim}
import csv import csv
...@@ -451,7 +451,7 @@ class UnicodeWriter: ...@@ -451,7 +451,7 @@ class UnicodeWriter:
self.encoding = encoding self.encoding = encoding
def writerow(self, row): def writerow(self, row):
self.writer.writerow([s.encode("utf-8") for s in row]) self.writer.writerow([s.encode(self.encoding) for s in row])
def writerows(self, rows): def writerows(self, rows):
for row in rows: for row in rows:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment