FAQ

I used the interpreter on my system:

import sys
sys.getdefaultencoding()
'ascii'

OK
from cStringIO import StringIO
b = StringIO()
b.write('%d:%s' % (len('string'), 'string'))
print b.getvalue()
6:string

OK
c = StringIO()
c.write('%d:%s' % (len('string?'), 'string?'))
print c.getvalue()
7:string?

OK

Did StringIO just recognize Extended ASCII?
Did StringIO just recognize ISO 8859-1?

? belongs to Extended ASCII AND ISO 8859-1.
print c.getvalue().decode('US-ASCII')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
UnicodeDecodeError: 'ascii' codec can't decode byte 0x82 in position 8: ordinal
not in range(128)
print c.getvalue().decode('ISO-8859-1')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python23\lib\encodings\cp437.py", line 18, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\x82' in position 8
: character maps to <undefined>
>>>

OK

It must have been Extended ASCII, then.

I must do other tests.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 12 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedJan 15, '04 at 7:38p
activeJan 17, '04 at 9:10a
posts12
users5
websitepython.org

People

Translate

site design / logo © 2018 Grokbase