Python 2.5 (r25:51908, Oct 6 2006, 15:24:43)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu4)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
'a'
'a'
u'a'
'a\x00\x00\x00'
I would have thought StringIO and cStringIO would return the
same result for this ascii-encodeable string. Worse:
u'a'
does the right thing, but
u'a\x00\x00\x00 '
looks bogus. Am I misunderstandin g something?
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu4)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
>>import StringIO, cStringIO
>>StringIO.Stri ngIO('a').getva lue()
>>StringIO.Stri ngIO('a').getva lue()
>>cStringIO.Str ingIO('a').getv alue()
>>StringIO.Stri ngIO(u'a').getv alue()
>>cStringIO.Str ingIO(u'a').get value()
>>>
same result for this ascii-encodeable string. Worse:
>>StringIO.Stri ngIO(u'a').getv alue().encode(' utf-8').decode('utf-8')
does the right thing, but
>>cStringIO.Str ingIO(u'a').get value().encode( 'utf-8').decode('utf-8')
looks bogus. Am I misunderstandin g something?
Comment