[IronPython] Reading Text files with open
Michael Foord
fuzzyman at voidspace.org.uk
Tue Jun 12 01:04:29 CEST 2007
Hello all,
If I create a file with the following code:
open(r'c:\temp\test.txt', 'w').write('\xa33')
And then read it in using the Python 'open', I get different results
with Python and IronPython:
CPython 2.4.4:
>>> data = open(r'c:\temp\test.txt').read()
>>> data
'\xa33'
>>> ord(data[0])
163
IronPython 1.1:
>>> data = open(r'c:\temp\test.txt').read()
>>> data
'?3'
>>> ord(data[0])
63
If I use the 'rb' flag with IronPython then the right thing happens, but
this isn't binary data...
Is there any way round this - I guess it is a consequence of .NET strings.
Michael
More information about the Ironpython-users
mailing list