# Not a real fiddle, but a quick note about my least-favorite topic: character encodings. # On Windows (and pythonfiddle.com) you will get an error trying to run this Python code: try: print u'\u2013' except UnicodeEncodeError as e: print e # UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 0: ordinal not in range(128) # We're trying to write the unicode 2013, or EN DASH. It looks like this: β (as opposed to the more common hypen, -). Side by side β- # It's an easy character to miss when you're trying to look through a document looking for funny looking characters that are causing # your python script to crash. # The Windows terminal can't display \u2013, but IDLE can, so if you run that line of code in idle, everything is fine. This is because # the stdard out device character support is different. import sys print sys.stdout.encoding # If you run this in IDLE, it will probably say something different. It's strange that two termianls on the same OS have different character # encodings. We can at least change the Windows terminal. # # Type chcp to see your current terminal encoding. It will probably be code page (cp) 437, which is the ASCII variant. Switch it to the 1252 # variant and you're good to go. # # chcp 1252 # # You'll also need to be sure you're using a truetype font and not a raster font, but it's pretty weird if you're still using one of those.
Run
Reset
Share
Import
Link
Embed
Language▼
English
δΈζ
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question