[IronPython] reading utf-8 files
abdalla ramadan
abdollaramadan.dev at gmail.com
Fri Jul 9 20:46:11 CEST 2010
Hello,
I am trying to read utf-8 files (written using notepad and have BOM) using
the following code
file = codecs.open(dir+ '\\' + i,"r",'utf_8_sig')
for line in file:
print "line"
I attached two files the a - 3 lines.txt file gives this exception and print
"line" is never called not even once
Unhandled Exception: System.Text.EncoderFallbackException: failed to decode
bytes at index 65
but the file a - 2 lines.txt is read without problems
I tried with several different texts but I could not find rule for a file
that throws this exception. I tested other files with 3 lines that did not
throw the exception.
Thanks very much for advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100709/3e7adc13/attachment.html>
-------------- next part --------------
?????????
????????
-------------- next part --------------
?????????
????????
????????
More information about the Ironpython-users
mailing list