1. Home
  2. Computing & Technology
  3. Python

Beginning Python: Python Encodings

From , former About.com Guide

1 of 7

The Reason for Encodings in Python

Anyone who lives on this planet long enough knows that more than one langauge is spoken on it. Anyone who programs long enough knows that data comes in more forms than simple, English ASCII. It was not always so. Thirty years ago, anyone who worked on computers had only the basic English character range to use. If they needed to talk about a piñata, they would type it "pinata" and need to disambiguate it as a part of a Mexican celebration by other means.

Eventually, different sets of characters came to be used to represent the sundry language communities in the world. They were, however, mapped over the same key values as their American English counterparts. Key values come in four part combinations like "0xdf". For American English, this could be mapped, say, to the lowercase letter 'a'. But in French, that value is mapped to the letter 'q' because French keyboards conventionally have 'q' where American keyboards have 'a' and 'a' where American keyboards have 'q'.

The trouble in multilingual programming comes because, when processing text, the computer operates on these values, not the letters. By default, Python uses North American English. However, it readily uses any other alphabet in the world; you simply need to tell it do so. This tutorial shows you how to save character strings as Unicode, how to convert Unicode strings to standard string format, and how to convert standard strings to Unicode.

Other tutorials in this series: 1 | 2 | 3 | 4 | 5 | 6

Explore Python
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Python
  4. Beginning Python
  5. Beginning Python: Python Encodings

©2009 About.com, a part of The New York Times Company.

All rights reserved.