In Python 2.x, is it possible to make unicode as default like in Python 3.x?

G00gle and Python Lover pythech.tr at gmail.com
Wed Jun 8 14:22:06 EDT 2011


Hello.
I almost like everything in Python. Code shrinking, logic of processes,
libraries, code design etc.
But, we... - everybody knows that Python 2.x has lack of unicode support.
In Python 3.x, this has been fixed :) And I like 3.x more than 2.x
But, still major applications haven't been ported to 3.x like Django.
Is there a way to make 2.x behave like 3.x in unicode support?
Is it possible to use Unicode instead of Ascii or remove ascii?
Python with ascii sucks :S
I know:

>>> lackOfUnicodeSupportAnnoys = u'Yeah I finally made it! Should be a
> magical thing! Unmögötich! İnanılmaz! Süper...'
>
>>> print lackOfUnicodeSupportAnnoys
>
Yeah I finally made it! Should be a magical thing! Unmögötich!
*Ýnanýlmaz!*Süper...
>
>>> *# You see the Turkish characters are not fully supported...*
>
>>> print str(lackOfUnicodeSupportAnnoys)
>

> *Traceback (most recent call last):**
> *
>
* File "<pyshell#7>", line 1, in <module>**
> *
>
* print str(lackOfUnicodeSupportAnnoys)**
> *
>
*UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in
> position 54: ordinal not in range(128)*
>
>>> *# Encode decode really sucks...*
>
>>> lackOfUnicodeSupportAnnoys = 'Yeah I finally made it! Should be a
> magical thing! Unmögötich! İnanılmaz! Süper...'
>
>>> *# Look that I didn't use 'u'*
>
>>> print lackOfUnicodeSupportAnnoys
>
Yeah I finally made it! Should be a magical thing! Unmögötich!
*İnanılmaz!*Süper...
>
>>> *# This time it worked, strange...*
>
>>> lackOfUnicodeSupportAnnoys = unicode('Yeah I finally made it! Should be
> a magical thing! Unmögötich! İnanılmaz! Süper...')
>

> *Traceback (most recent call last):**
> *
>
* File "<pyshell#10>", line 1, in <module>**
> *
>
* lackOfUnicodeSupportAnnoys = unicode('Yeah I finally made it! Should be a
> magical thing! Unmögötich! İnanılmaz! Süper...')**
> *
>
*UnicodeDecodeError: 'ascii' codec can't decode byte 0xf6 in position 54:
> ordinal not in range(128)*
>
>>> *# Some annoying error again*
>
>>> lackOfUnicodeSupportAnnoys
>
'Yeah I finally made it! Should be a magical thing! Unm\xf6g\xf6tich!
> \xddnan\xfdlmaz! S\xfcper...'
>
>>> *# And finally, most annoying thing isn't it? *
>
*
*
Thanks...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110608/b3000d27/attachment.html>


More information about the Python-list mailing list