encodings.idna.ToASCII( unicodeStr ) != unicodeStr.encode( 'idna' )
python at bdurham.com
python at bdurham.com
Tue Jun 22 10:02:58 EDT 2010
Python 2.6.4 (Win32): Anyone have any explanation for the
following
encodings.idna.ToASCII( unicodeStr ) != unicodeStr.encode( 'idna'
)
Given that other processes may have to use the output of these
methods, what is the recommended technique?
Demonstration:
>>> import encodings.idna
>>> name = u'junk\xfc\xfd.txt'
>>> name
u'junk\xfc\xfd.txt'
>>> encodings.idna.ToASCII( name )
'xn--junk.txt-95ak'
>>> name.encode( 'idna' )
'xn--junk-3rag.txt'
>>> encodings.idna.ToUnicode( encodings.idna.ToASCII( name ) )
u'junk\xfc\xfd.txt'
>>> name.encode( 'idna' ).decode( 'idna' )
u'junk\xfc\xfd.txt'
The good news is that the encodings.idna and string idna
transformations appear to properly mirror when used with their
matching transformation.
The bad news is that encodings.idna and the equivalent str
transformations can't be intermixed.
Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100622/9b06adb8/attachment.html>
More information about the Python-list
mailing list