All formats

Text encoding libraries for Python

Python’s built-in codecs read and write every common encoding (open(path, encoding="cp1252"), "utf-8-sig" strips a BOM, "utf-16" handles one). What Python lacks is detection:

Both have a detect() function with the same return shape, so you can swap them.