]> granicus.if.org Git - python/commitdiff
Bug #1440831: fix csv UnicodeWriter example
authorGeorg Brandl <georg@python.org>
Tue, 7 Mar 2006 13:47:22 +0000 (13:47 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 7 Mar 2006 13:47:22 +0000 (13:47 +0000)
Doc/lib/libcsv.tex

index 22cfda5e444b9ddb74fe6fab394396f1e3a92cac..ba0df4fcd52e23fadc4e7cadb4531ff15b452cd5 100644 (file)
@@ -428,7 +428,7 @@ for row in csv.reader(['one,two,three']):
 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
 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}
 import csv
@@ -451,7 +451,7 @@ class UnicodeWriter:
         self.encoding = encoding
 
     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):
         for row in rows: