stclib / STC

A modern, user friendly, generic, type-safe and fast C99 container library: String, Vector, Sorted and Unordered Map and Set, Deque, Forward List, Smart Pointers, Bitset and Random numbers.
MIT License
1.34k stars 73 forks source link

singleheader.py fixes for Windows and newer Python #74

Closed sgraham closed 1 year ago

sgraham commented 1 year ago

Windows assumes cp1252 resulting in:

  ...
  File "...\STC\src\singleheader.py", line 47, in process_file
    process_file(
  File "...\STC\src\singleheader.py", line 28, in process_file
    for line in f:
  File "C:\Program Files\Python312\Lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 426: character maps to <undefined>

Additionally, \* seems to have changed in recent Py3 versions (?), so they need an extra backslash:

...\STC\src\singleheader.py:30: SyntaxWarning: invalid escape sequence '\*'
  if re.search('/\*.*?\*/', line):
tylov commented 1 year ago

Thanks. I have enabled "Beta:Use Unicode UTF-8 for worldwide language support" in the system locale settings in windows, so I don't notice this kind of issues.