csv encoding

main
Bob Mottram 2021-07-28 11:04:47 +01:00
parent ef606161a1
commit 35a1a3ecc9
2 changed files with 3 additions and 4 deletions

View File

@ -10800,8 +10800,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.httpPrefix, self.server.httpPrefix,
self.server.domainFull, self.server.domainFull,
self.path) self.path)
msg = json.dumps(catalogStr, msg = msg.encode('utf-8')
ensure_ascii=False).encode('utf-8')
msglen = len(msg) msglen = len(msg)
self._set_headers('text/csv', self._set_headers('text/csv',
msglen, None, callingDomain) msglen, None, callingDomain)

View File

@ -963,7 +963,7 @@ def sharesCatalogCSVEndpoint(baseDir: str, httpPrefix: str,
return '' return ''
csvStr = \ csvStr = \
'id,type,hasType,startDate,expiryDate,' + \ 'id,type,hasType,startDate,expiryDate,' + \
'quantity,price,currency,Image,description,\r\n' 'quantity,price,currency,Image,description,\n'
for item in catalogJson['DFC:supplies']: for item in catalogJson['DFC:supplies']:
csvStr += '"' + item['@id'] + '",' csvStr += '"' + item['@id'] + '",'
csvStr += '"' + item['@type'] + '",' csvStr += '"' + item['@type'] + '",'
@ -975,7 +975,7 @@ def sharesCatalogCSVEndpoint(baseDir: str, httpPrefix: str,
csvStr += '"' + item['DFC:price'].split(' ')[1] + '",' csvStr += '"' + item['DFC:price'].split(' ')[1] + '",'
csvStr += '"' + item['DFC:Image'] + '",' csvStr += '"' + item['DFC:Image'] + '",'
description = item['DFC:description'].replace('"', "'") description = item['DFC:description'].replace('"', "'")
csvStr += '"' + description + '",\r\n' csvStr += '"' + description + '",\n'
return csvStr return csvStr