The American Standard Code for Information Interchange, or ASCII, encoding defines codes for English characters, punctuation marks and special symbols with the numeric values running from 0 to 127. When you want to read or store non-ASCII characters, such as characters in foreign alphabets or accented English letters, in the Python programming language, you must convert them to the closest visual equivalents of ASCII characters in Python supported encoding. By using Python's unicode function you can present non-ASCII characters in user applications.
- Skill level:
Other People Are Reading
Things you need
- Python IDLE 2.7.1
Click "Start" in Windows and then click "Notepad" to open Notepad text editor.
Add the following code in the open window:
raw = 'A'.decode('cp437')
txt = unicode('A', encoding='utf-8')
Click "File" and then click "Save.' Enter "nonascii.py" in the "File Name" box and click the "Save' button.
Click "Start" in Windows, select "Python 2.7" and then click "IDLE (Python GUI)." Click "File", select "Open" and then double-click on the "nonascii.py" in the open window.
Click "Run" and then click "Run Module" to decode non-ASCII "A" character in the "CP437" encoding to the "UTF-8" encoding.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for