Skip to main content

has_bom

Checks if a file starts with a UTF-8 or UTF-16 Byte Order Mark (BOM) by reading the first four bytes of the specified file path.

def has_bom(
fn: Path
) - > boolean

Checks if a file starts with a Byte Order Mark (BOM) for UTF-8 or UTF-16 encodings.

Parameters

NameTypeDescription
fnPathA pathlib.Path object representing the file to be inspected for encoding signatures.

Returns

TypeDescription
booleanTrue if the file contains a UTF-8, UTF-16-LE, or UTF-16-BE byte order mark, otherwise False.