Skip to content

Use UTF-8 encoding when reading doc.json - #100

Merged
taminomara merged 1 commit into
sphinx-contrib:mainfrom
vlazed:utf-8-patch
Sep 8, 2026
Merged

taminomara merged 1 commit into
sphinx-contrib:mainfrom
vlazed:utf-8-patch

Conversation

@vlazed

@vlazed vlazed commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

I ran into the following error when generating docs for my project:

    sphinx.errors.ExtensionError: Handler <function run_lua_ls at 0x000001CA532368D0> for event 'builder-inited' threw an exception (exception: 'cp932' codec can't decode byte 0x94 in position 27401: illegal multibyte sequence)

From some reading on the error, I found this had to do with my PC being set to the Japanese locale (cp932 means Code Page 932).

Changing the return statement in the run function of lua_ls.py to use UTF-8 encoding fixed it (which this PR includes)

return json.loads(
     pathlib.Path(output_path, "doc.json").read_text(encoding="utf-8") # Add `encoding="utf-8"`
)

I only verified it working for the Japanese codec, but I assume this should fix encoding errors in other languages

@taminomara
taminomara merged commit dcdbf76 into sphinx-contrib:main Sep 8, 2026
7 checks passed
@taminomara

Copy link
Copy Markdown
Collaborator

Released in v3.12.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants