<div dir="ltr"><div>Hello,</div><div><br></div><div>I am trying to read utf-8 files (written using notepad and have BOM) using the following code</div><div><br></div><div>file = codecs.open(dir+ '\\' + i,"r",'utf_8_sig')</div>
<div>for line in file:</div><div> print "line"</div><div><br></div><div>I attached two files the a - 3 lines.txt file gives this exception and print "line" is never called not even once</div><div><br>
</div><div><div>Unhandled Exception: System.Text.EncoderFallbackException: failed to decode bytes at index 65</div></div><div><br></div><div>but the file a - 2 lines.txt is read without problems</div><div><br></div><div>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.</div>
<div><br></div><div>Thanks very much for advance</div></div>