[Ironpython-users] Utility function for encoding detection

Michael Foord mfoord at python.org
Mon Oct 10 17:42:59 CEST 2011


On 10/10/2011 15:53, Markus Schaber wrote:
> Hi,
>
> For our embedded IronPython, we need to convert python scripts from string to files and back. To do that, I need to know the encoding of the python source for both ways, if there's one specified according to PEP 0263. (Our intended fallback is to UTF8 with BOM if none is specified.)
>
> Are there any public utility functions in IronPython I can call to detect encoding markers in files and in strings?

Python 3 has a "detect_encoding" function in the tokenize module that 
does this. You could copy and reuse that.

Michael Foord

> Best regards
>
> Markus Schaber


-- 
http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html



More information about the Ironpython-users mailing list