On 16 August 2016 at 15:51, Mike Dewhirst <[email protected]> wrote:

> Output with different code page settings ...
>
>                 line = line.encode("utf-8").decode("cp1252", "replace")
>
> , ',', '\x00', ',', '\x00', ',', '\x00', ',', '\x00', '0', '\x00', '.',
> '\x00', '0', '\x00',
>  '0', '\x00', '0', '\x00', '0', '\x00', '0', '\x00', '%', '\x00', ',',
> '\x00', '"', '\x00',
> '"', '\x00', ',', '\x00', '"', '\x00', '"', '\x00', ',', '\x00', '"',
> '\x00', 'A', '\x00', '
> d', '\x00', 'd', '\x00', 'i', '\x00', 't', '\x00', 'i', '\x00', 'o',
> '\x00', 'n', '\x00', 'a
> ', '\x00', 'l', '\x00', ' ', '\x00', 'N', '\x00', 'o', '\x00', 'n',
> '\x00', '-', '\x00', 'G'
> , '\x00', 'H', '\x00', 'S', '\x00', ' ', '\x00', 'H', '\x00', 'a', '\x00',
> 'z', '\x00', 'a',
>  '\x00', 'r', '\x00', 'd', '\x00', ' ', '\x00', 'S', '\x00', 't', '\x00',
> 'a', '\x00', 't',
> '\x00', 'e', '\x00', 'm', '\x00', 'e', '\x00', 'n', '\x00', 't', '\x00',
> '"', '\x00', ',', '
> \x00', ',', '\x00', '0', '\x00', '.', '\x00', '0', '\x00', '0', '\x00',
> '0', '\x00', '0', '\
> x00', '0', '\x00', '%', '\x00', ',', '\x00', '"', '\x00', '"', '\x00', '\n'
>

​Illustrative: you're opening a UTF-16 file with the default encoding of
utf-8.

​open(csvfile, 'r', encoding='UTF-16')​


-- 
William Leslie

Notice:
Likely much of this email is, by the nature of copyright, covered under
copyright law.  You absolutely MAY reproduce any part of it in accordance
with the copyright law of the nation you are reading this in.  Any attempt
to DENY YOU THOSE RIGHTS would be illegal without prior contractual
agreement.
_______________________________________________
melbourne-pug mailing list
[email protected]
https://mail.python.org/mailman/listinfo/melbourne-pug

Reply via email to