Skip to content

Commit 66c1e12

Browse files
author
Richard Jones
committed
CSV encoding support [SF#1240848]
1 parent 94f0704 commit 66c1e12

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Feature:
1919
- classhelp works with Link properties now (sf bug 1410290)
2020
- added setorderprop() and setlabelprop() to Class (sf features 1379534,
2121
1379490)
22+
- CSV encoding support (sf bug 1240848)
2223

2324
Fixed:
2425
- MySQL now creates String columns using the TEXT column type

roundup/cgi/actions.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#$Id: actions.py,v 1.54 2006-01-23 03:42:27 richard Exp $
1+
#$Id: actions.py,v 1.55 2006-01-25 03:14:40 richard Exp $
22

3-
import re, cgi, StringIO, urllib, Cookie, time, random, csv
3+
import re, cgi, StringIO, urllib, Cookie, time, random, csv, codecs
44

55
from roundup import hyperdb, token, date, password
66
from roundup.i18n import _
@@ -961,7 +961,7 @@ def handle(self):
961961
matches = None
962962

963963
h = self.client.additional_headers
964-
h['Content-Type'] = 'text/csv'
964+
h['Content-Type'] = 'text/csv; charset=%s' % self.client.charset
965965
# some browsers will honor the filename here...
966966
h['Content-Disposition'] = 'inline; filename=query.csv'
967967

@@ -971,7 +971,12 @@ def handle(self):
971971
# all done, return a dummy string
972972
return 'dummy'
973973

974-
writer = csv.writer(self.client.request.wfile)
974+
wfile = self.client.request.wfile
975+
if self.client.charset != self.client.STORAGE_CHARSET:
976+
wfile = codecs.EncodedFile(wfile,
977+
self.client.STORAGE_CHARSET, self.client.charset, 'replace')
978+
979+
writer = csv.writer(wfile)
975980
writer.writerow(columns)
976981

977982
# and search

0 commit comments

Comments
 (0)