[melbourne-pug] Unicode for windows dummies
Mike Dewhirst
miked at dewhirst.com.au
Tue Aug 16 03:31:16 EDT 2016
On 16/08/2016 5:17 PM, William ML Leslie wrote:
> , encoding='UTF-16'
Output snippet shown below ...
with open(csvfile, "r", encoding='utf-16') as csv:
i = 0
self.rows = csv.readlines()
for line in self.rows:
#line = line.encode("utf-8").decode("cp1252", "replace")
#line = line.encode("cp1252").decode("cp1252", "replace")
#line = line.encode("cp1252")
line = line.encode("utf-8")
i += 1
cells = list(line)
# this requires a bytes-like object not 'str'
#cells = line.split(",")
if i >= start:
# as expected this includes the [] brackets around each row
print(cells)
# this omits the [] brackets but otherwise output is identical
#print(', '.join(repr(cell) for cell in cells))
if i > finish:
break
... 118, 105, 114, 111, 110, 109, 101, 110, 116, 46, 34, 44, 44, 44, 44,
44, 44, 44, 48, 46, 48,
48, 48, 48, 48, 37, 44, 34, 34, 44, 44, 34, 34, 44, 34, 34, 44, 34,
34, 44, 34, 34, 44, 34,
67, 104, 114, 111, 110, 105, 99, 32, 72, 97, 122, 97, 114, 100, 32,
84, 111, 32, 84, 104, 1
01, 32, 65, 113, 117, 97, 116, 105, 99, 32, 69, 110, 118, 105, 114, 111,
110, 109, 101, 110,
116, 46, 34, 44, 50, 44, 34, 78, 47, 65, 34, 44, 34, 71, 72, 83, 48,
57, 34, 44, 34, 72, 52
, 49, 49, 34, 44, 44, 44, 48, 46, 48, 48, 48, 48, 48, 37, 44, 34, 34,
44, 44, 34, 34, 44, 34
, 34, 44, 34, 34, 44, 34, 34, 44, 34, 34, 44, 34, 72, 97, 122, 97, 114,
100, 111, 117, 115,
32, 84, 111, 32, 84, 104, 101, 32, 79, 122, 111, 110, 101, 32, 76, 97,
121, 101, 114, 46, 34
, 44, 44, 44, 44, 44, 48, 46, 48, 48, 48, 48, 48, 37, 44, 34, 34, 44,
34, 34, 44, 34, 65, 10
0, 100, 105, 116, 105, 111, 110, 97, 108, 32, 78, 111, 110, 45, 71, 72,
83, 32, 72, 97, 122,
97, 114, 100, 32, 83, 116, 97, 116, 101, 109, 101, 110, 116, 34, 44,
34, 65, 85, 72, 48, 54
, 54, 34, 44, 48, 46, 48, 48, 48, 48, 48, 37, 44, 34, 34, 10]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/melbourne-pug/attachments/20160816/05a28912/attachment.html>
More information about the melbourne-pug
mailing list