Python Forum

Full Version: how to print unicode in python?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
the goal is to have a 100% unicode system with utf-8 being used in any/every 8-bit or 9-bit (or up to 15-bit) stream/storage.  file names, file contents, internet connections, are typically 8-bit.  i once developed a 1-36 bit wrapper for the DECsystem-20 TOPS-20 system and IBM System-360 MVS and later did a 1-32 bit version for Linux (which compiled unchanged in Windows and worked compatibly).  anyway, back to unicode, utf-8, and python.  when might we have it so we just type in any unicode character in a text string (as a source code literal or as input() data).  python 4 ?

i want to be able to print() a text string with unicode characters in it and have it come out right (the correct datacodes when redirected to a file and the correct character displayed on a terminal screen or printer).
Read more about this.
Unicode HOWTO
Quote:Since Python 3.0, the language features a str type that contain Unicode characters,
meaning any string created using "unicode rocks!", 'unicode rocks!', or the triple-quoted string syntax is stored as Unicode.

The default encoding for Python source code is UTF-8, so you can simply include a Unicode character in a string literal:
Python 3 is all Unicode,problem can of course occurs because the outside world(OS,Files,Terminals,Files,Servers...)that are not all Unicode.
There has been massive discussion about this topic,
many correction has been made and Python 3.5 --> are really good(also talking with outside world).
Python 3 decision to make all Unicode was the right decision,we have to hope that it get better in the outside world.

Just a note all Shell/Terminal(Windows,Linux,Mac) can get correct arguments in Unicode into Python.
Bye using Click click.echo().
Quote:but it has improved support for handling Unicode and binary data
that does not fail no matter how badly configured the system is.

Primarily it means that you can print binary data as well as Unicode data on both 2.x and 3.x to the given file in the most appropriate way possible.
This is a very carefree function as in that it will try its best to not fail.
As of Click 6.0 this includes support for Unicode output on the Windows console.