Skip to content

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte #3191

@gabrielsanbrito

Description

@gabrielsanbrito

This happens on Windows. I noticed that a Bikeshed template created with bikeshed template > index.bs apparently has the "UTF-16 LE" encoding. This results in the following parsing errors when calling bikeshed spec index.bs index.html:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\users\<user>\.local\bin\bikeshed.exe\__main__.py", line 6, in <module>
  File "C:\Users\<user>\pipx\venvs\bikeshed\Lib\site-packages\bikeshed\cli.py", line 480, in main
    handleSpec(options, extras)
  File "C:\Users\<user>\pipx\venvs\bikeshed\Lib\site-packages\bikeshed\cli.py", line 527, in handleSpec
    doc = Spec(
          ^^^^^
  File "C:\Users\<user>\pipx\venvs\bikeshed\Lib\site-packages\bikeshed\Spec.py", line 87, in __init__
    self.valid = self.initializeState()
                 ^^^^^^^^^^^^^^^^^^^^^^
    self.valid = self.initializeState()
ckages\bikeshed\Spec.py", line 125, in initializeState
ckages\bikeshed\Spec.py", line 125, in initializeState
    self.inputContent = self.inputSource.read()
    self.inputContent = self.inputSource.read()
ckages\bikeshed\InputSource.py", line 205, in read
    f.readlines(),
    ^^^^^^^^^^^^^
  File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

To fix it I need to manually make VSCode change the file encoding to UTF-8. Is this expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions