<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+ &#39;\\&#39; + i,&quot;r&quot;,&#39;utf_8_sig&#39;)</div>
<div>for line in file:</div><div>    print &quot;line&quot;</div><div><br></div><div>I attached two files the a - 3 lines.txt file gives this exception and print &quot;line&quot; 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>