Skip to content

Commit

Permalink
Merge pull request #99 from nk9/nk-bom
Browse files Browse the repository at this point in the history
Add README text explaining how to easily strip a BOM from a UTF-8 file.
  • Loading branch information
eyeseast authored Nov 21, 2022
2 parents 56585c7 + 50471e3 commit 3910ac7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ Or load from text:

```

If the file has a [Byte-Order Mark](https://en.wikipedia.org/wiki/Byte_order_mark) (BOM), strip it off first. An easy way to do this is by using the [`utf-8-sig`](https://docs.python.org/3/library/codecs.html?highlight=utf%208%20sig#module-encodings.utf_8_sig) encoding:

```python
>>> with open('tests/yaml/hello-world.txt', encoding="utf-8-sig") as f:
... post = frontmatter.load(f)

```

Access content:

```python
Expand Down

0 comments on commit 3910ac7

Please sign in to comment.