Mandy-cyber / Markdown-ToC-Generator

Generates and writes in a table of contents for a given markdown file
MIT License
2 stars 4 forks source link

[BUG]: Encoding Error when Reading Markdown Files on Windows: 'charmap' codec can't decode byte 0x90 #7

Closed A1r0x closed 9 hours ago

A1r0x commented 10 hours ago

Description

When running the markdown file reader script on Windows, I encounter the following error while reading the sample.md markdown file:

'charmap' codec can't decode byte 0x90 in position 727: character maps to <undefined>

Steps to Reproduce:

  1. Go on a Windows PC
  2. Run Python mdtoc sample.md <dest_file>
  3. Observe the charmap codec error

Expected behavior

The file should be read without raising an encoding-related error.

Suggested fix

explicitly set the encoding to utf-8 when reading the file: data = Path(file_name).read_text(encoding='utf-8')