@@ -801,39 +801,31 @@ \subsection{Unicode Strings \label{unicodeStrings}}
801801other ways of creating Unicode strings on the basis of a known
802802encoding.
803803
804- The builtin \function {unicode()}\bifuncindex {unicode} provides access
804+ The built-in function \function {unicode()}\bifuncindex {unicode} provides access
805805to all registered Unicode codecs (COders and DECoders). Some of the
806806more well known encodings which these codecs can convert are
807807\emph {Latin-1 }, \emph {ASCII }, \emph {UTF-8 } and \emph {UTF-16 }. The latter two
808- are variable length encodings which permit to store Unicode characters
809- in 8 or 16 bits. Python uses UTF-8 as default encoding. This becomes
810- noticeable when printing Unicode strings or writing them to files .
808+ are variable- length encodings which store Unicode characters
809+ in blocks of 8 or 16 bits. To print a Unicode string or write it to a file,
810+ you must convert it to a string with the \method {encode()} method .
811811
812812\begin {verbatim }
813813>>> u"äöü"
814814u'\344\366\374'
815- >>> str( u"äöü")
815+ >>> u"äöü".encode('UTF-8' )
816816'\303\244\303\266\303\274'
817817\end {verbatim }
818818
819819If you have data in a specific encoding and want to produce a
820820corresponding Unicode string from it, you can use the
821- \function {unicode()} builtin with the encoding name as second
821+ \function {unicode()} function with the encoding name as second
822822argument.
823823
824824\begin {verbatim }
825825>>> unicode('\303\244\303\266\303\274','UTF-8')
826826u'\344\366\374'
827827\end {verbatim }
828828
829- To convert the Unicode string back into a string using the original
830- encoding, the objects provide an \method {encode()} method.
831-
832- \begin {verbatim }
833- >>> u"äöü".encode('UTF-8')
834- '\303\244\303\266\303\274'
835- \end {verbatim }
836-
837829
838830\subsection {Lists \label {lists } }
839831
0 commit comments