Python Glossary Русский

all Python 3codecsterm

codecs.BOM_UTF32_BE

byte order marks (BOM)

The bytes b'\x00\x00\xfe\xff', the UTF-32 big-endian byte order mark. The 'utf-32' decoder uses it to pick the order and strips it.

Syntax

codecs.BOM_UTF32_BE  # b'\x00\x00\xfe\xff'

It starts with two zero bytes, so text tools often mistake such a file for binary. As with UTF-16, the explicit-order codec ('utf-32-be') does not strip the mark, leaving '\ufeff' in the text. The legacy name BOM64_BE is the same object.

Examples

import codecs
data = codecs.BOM_UTF32_BE + 'ok'.encode('utf-32-be')
print(data.decode('utf-32'))  # → ok
print(len(data))  # → 12

See also

Open in the full glossarydocs.python.orgReport an inaccuracy