[IronPython] Weird issue with codecs.BOM_UTF8

Michael Foord fuzzyman at voidspace.org.uk
Tue Nov 10 22:16:34 CET 2009


Leonides Saguisag wrote:
> Hi everyone,
>
> I am encountering a weird issue with getting to codecs.BOM_UTF8 to work correctly.  I am using SharpDevelop 3.1.
>
> Here is the test script that I put together:
>
>
> import sys
> sys.path.append(r'D:\Python25\Lib')
> import codecs
>
> print sys.version
> myfile = open(r'D:\Temp\text_file_with_utf8_bom.txt', 'r')
> lines = myfile.readlines()
> myfile.close()
> if lines[0].startswith(codecs.BOM_UTF8):
> 	print ('UTF-8 BOM detected!')
> else:
> 	print ('UTF-8 BOM not detected!')
>
> myfile = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r')
> lines = myfile.readlines()
> myfile.close()
> if lines[0].startswith(codecs.BOM_UTF8):
> 	print ('UTF-8 BOM detected!')
> else:
> 	print ('UTF-8 BOM not detected!')
>
>
> If I run the executable that I get from SharpDevelop this is what I get:
> bin\Debug> Test.exe
> 2.5.0 ()
> UTF-8 BOM detected!
> UTF-8 BOM detected!
>
>
> But if I run the same script using the standard python interpreter, this is what I get:
> bin\Debug> D:\Python25\python.exe ..\..\Program.py
> 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)]
> UTF-8 BOM detected!
> UTF-8 BOM not detected!
>
>
> The script works correctly with the standard python interpreter but for some reason is not working right with IronPython.
>
> Any ideas what is going wrong?
>   
I'm not in a position to check right now, but this could happen if 
codes.UTF8_BOM is set to the empty string.

Michael

> Thanks!
>
> Best regards,
> -- Leo
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   


-- 
http://www.ironpythoninaction.com/




More information about the Ironpython-users mailing list