Mega Code Archive

 
Categories / Python / Language Basics
 

Built-in function unicode() provides access to all registered Unicode codecs

#Built-in function unicode() provides access to all registered Unicode codecs  #(COders and DECoders).  #Some of the more well known encodings which these codecs can convert are Latin-1,  #ASCII, UTF-8, and UTF-16.   #The latter two are variable-length encodings that store each Unicode character in  #one or more bytes. The default encoding is normally set to ASCII, which passes  #through characters in the range 0 to 127 and rejects any other characters with an  #error. When a Unicode string is printed, written to a file, or converted with  #str(), conversion takes place using this default encoding. print u"abc" print str(u"abc") print u"\0102" print str(u"\0104")