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
九州看看看看看看
九州看看看看看看

九州看看看看看看
九州看看看看看看
九州看看看看看看

_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to