I have figured out how to use the characters I need but it works differently in the console on linux versus the windows console. I want to figure out if there is a way to resolve this where I can make it work on both or at least check to see what system it is running on and call the right code.
This is using the Coding Ground terminal at http://www.tutorialspoint.com/execute_python_online.php
It uses Fedora Release 21 and Python v2.7.5. This is my initial code:
# Unicode Test
print u'\u2554'
This gives me this error:
Traceback (most recent call last):
File "main.py", line 2, in <module>
print u'\u2554'
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2554' in position 0: ordinal not in range(128)
On Windows 7 console using Python 2.7.9 this runs correctly and prints the '╔' character. To make it run correctly on the linux terminal I have to use
# Unicode Test
print u'\u2554'.encode('UTF-8')
Unfortunately this code will not run correctly under the Windows console. If I use print u'\u2554'.encode('UTF-8')
on Windows I get b'\xe2\x95\x94'
Any ideas on how I can make it run on both systems with out having to maintain different code for each console?