{ } Raw JSON

bundles / astropy latest / astropy / extern / configobj / configobj / ConfigObj / _handle_bom

function

astropy.extern.configobj.configobj:ConfigObj._handle_bom

source: /astropy/extern/configobj/configobj.py :1369

Signature

def   _handle_bom ( self infile )

Summary

Handle any BOM, and decode if necessary.

Extended Summary

If an encoding is specified, that must be used - but the BOM should still be removed (and the BOM attribute set).

(If the encoding is wrongly specified, then a BOM for an alternative encoding won't be discovered or removed.)

If an encoding is not specified, UTF8 or UTF16 BOM will be detected and removed. The BOM attribute will be set. UTF16 will be decoded to unicode.

NOTE: This method must not be called with an empty infile.

Specifying the wrong encoding is likely to cause a UnicodeDecodeError.

infile must always be returned as a list of lines, but may be passed in as a single string.

Aliases

  • astropy.config.configuration.configobj.ConfigObj._handle_bom