Michael Newman <michael.b.new...@gmail.com> added the comment: It seems to be working consistently (see UTF-16 extreme example below), but I had expected it to act similarly to Python 2.6, which it does not. I suppose this is due to the distinction now made between strings and bytes in Python 3.0.
I was initially concerned that Python 3.0 was always just giving an ASCII byte stream no matter what encoding was chosen (since you can't tell between ASCII and UTF-8 for the characters being used in the example), but the UTF-16 example shows its fine. I agree that as long as the documentation in Python 3.X notes it will return "bytes", then its fine. Thanks for the clarification/confirmation. Python 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import calendar >>> calendar.HTMLCalendar().formatyearpage(2009, encoding="utf-8")[0:50] b'<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE h' >>> calendar.HTMLCalendar().formatyearpage(2009, encoding="ascii")[0:50] b'<?xml version="1.0" encoding="ascii"?>\n<!DOCTYPE h' >>> calendar.HTMLCalendar().formatyearpage(2009, encoding="utf-16")[0:50] b'\xff\xfe<\x00?\x00x\x00m\x00l\x00 \x00v\x00e\x00r\x00s\x00i\x00o\x00n\x00=\x00"\x001\x00.\x000\x00"\x00 \x00e\x00n\x00c\x00o\x00' Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import calendar >>> calendar.HTMLCalendar().formatyearpage(2009, encoding="utf-8")[0:50] '<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE h' >>> calendar.HTMLCalendar().formatyearpage(2009, encoding="ascii")[0:50] '<?xml version="1.0" encoding="ascii"?>\n<!DOCTYPE h' >>> calendar.HTMLCalendar().formatyearpage(2009, encoding="utf-16")[0:50] '\xff\xfe<\x00?\x00x\x00m\x00l\x00 \x00v\x00e\x00r\x00s\x00i\x00o\x00n\x00=\x00"\x001\x00.\x000\x00"\x00 \x00e\x00n\x00c\x00o\x00' _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4973> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com