On 16 August 2016 at 17:12, William ML Leslie <[email protected]> wrote:
> > On 16 August 2016 at 15:28, Anthony Briggs <[email protected]> > wrote: >> >> That string is translated to a cp1252 character set, so I'd be surprised >> if it didn't work. >> >> OTOH, try utf-8 characters in a Windows Python REPL, and you don't even >> make it to the end of the string :) >> >> print("Mÿ hôvèrçràft îß fûll öf éêls") >> > > All of those characters are represented in cp1252 and can print on a > windows terminal, > *No, they can't! * Hint: I'm sitting in front of a Windows terminal. PS C:\Users\Anthony> python Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print("M├┐ h├┤v├¿r├ºr├áft ├«├ƒ f├╗┼él ├Âf ├®├¬l┼ø") M├┐ h├┤v├¿r├ºr├áft ├«├ƒ f├╗┼él ├Âf ├®├¬l┼ø >>> print("Mÿ hôvèrçràft îß fûll öf éêls") File "<stdin>", line 0 ^ SyntaxError: 'utf-8' codec can't decode byte 0x98 in position 8: invalid start byte >>> print("Mÿ hôvèrçràft îß fûll öf éêls".decode('utf-8')) File "<stdin>", line 0 ^ SyntaxError: 'utf-8' codec can't decode byte 0x98 in position 8: invalid start byte >>> print("Mÿ hôvèrçràft îß fûll öf éêls".decode('cp1252')) File "<stdin>", line 0 ^ SyntaxError: 'utf-8' codec can't decode byte 0x98 in position 8: invalid start byte >>> print("Mÿ hôvèrçràft îß fûll öf éêls".decode('cp1252', "replace")) File "<stdin>", line 0 ^ SyntaxError: 'utf-8' codec can't decode byte 0x98 in position 8: invalid start byte >>> And the results for your test code: PS C:\Users\Anthony> python Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> s = b'M\xc3\xbf h\xc3\xb4v\xc3\xa8r\xc3\xa7r\xc3\xa0ft \xc3\xae\xc3\x9f f\xc3\xbbll \xc3\xb6f \xc3\xa9\xc3\xaals' >>> print(s.decode('utf-8')) M├┐ h├┤v├¿r├ºr├áft ├«├ƒ f├╗ll ├Âf ├®├¬ls >>> t = u'given \u2113\u2081 = 7' >>> print(t) given ÔäôÔéü = 7 >>> print(t.encode("cp1252", "replace").decode("cp1252")) given ?? = 7 >>> print(t.encode("utf-8").decode("cp1252", "replace")) given ├óÔÇ×ÔÇ£├óÔÇÜ´┐¢ = 7 >>> Totally different. If you're not actually testing that what you're saying works, please stop confusing the issue. Anthony
_______________________________________________ melbourne-pug mailing list [email protected] https://mail.python.org/mailman/listinfo/melbourne-pug
