sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.18k stars 2.03k forks source link

chm charset cp1252 doesn't work on win10 #5206

Closed heuena closed 5 months ago

heuena commented 5 years ago

Problem

Test

Since hh.exe does not allow charset choosing, I test the page with IE. IE shows the page using default encoding GB2312, seems that 'charset=cp1252' is ignored. After changing "cp1252" to "Windows-1252", IE gets the right encoding and everything is ok. I also test "cp950" and "cp932", they are ignored either.

Environment info

TheNetos commented 2 years ago

+1 same problem

My stacktrace:

Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sphinx\cmd\build.py", line 280, in build_main
    app.build(args.force_all, filenames)
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sphinx\application.py", line 343, in build
    self.builder.build_update()
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sphinx\builders\__init__.py", line 293, in build_update
    self.build(to_build,
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sphinx\builders\__init__.py", line 360, in build
    self.finish()
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sphinx\builders\html\__init__.py", line 643, in finish
    self.finish_tasks.add_task(self.copy_static_files)
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sphinx\util\parallel.py", line 49, in add_task
    res = task_func()
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sphinx\builders\html\__init__.py", line 823, in copy_static_files
    context.update(self.indexer.context_for_searchtool())
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sphinx\search\__init__.py", line 427, in context_for_searchtool
    'search_language_stemming_code': self.get_js_stemmer_code(),
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sphinx\search\__init__.py", line 453, in get_js_stemmer_code
    language_js = js_file.read()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\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 152: character maps to <undefined>
azvoleff commented 2 years ago

I see the same (running on Windows 10 21H2):

# Sphinx version: 4.1.0
# Python version: 3.9.5 (CPython)
# Docutils version: 0.16 release
# Jinja2 version: 3.1.2
# Last messages:
#   copying images... [ 97%] ../resources/en/documentation/calculate/settings_dialog_algorithm_region_of_interest.png
#   copying images... [ 97%] ../resources/en/documentation/settings/settings_report.png
#   copying images... [ 98%] ../resources/en/documentation/reporting_tool/unccd_reporting_step2.png
#   copying images... [ 98%] ../resources/en/documentation/reporting_tool/sdg15_lpd_unccd_reporting.png
#   copying images... [ 99%] static/common/Logos_All_Partners.png
#   copying images... [ 99%] static/common/logo_earth_engine.png
#   copying images... [100%] static/common/trends_earth_logo_bl_1200.png
#   
#   copying static files...
#   failed
# Loaded extensions:
#   sphinx.ext.mathjax (4.1.0) from d:\anaconda\envs\te_py39\lib\site-packages\sphinx\ext\mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from d:\anaconda\envs\te_py39\lib\site-packages\sphinxcontrib\applehelp\__init__.py
#   sphinxcontrib.devhelp (1.0.2) from d:\anaconda\envs\te_py39\lib\site-packages\sphinxcontrib\devhelp\__init__.py
#   sphinxcontrib.htmlhelp (2.0.0) from d:\anaconda\envs\te_py39\lib\site-packages\sphinxcontrib\htmlhelp\__init__.py
#   sphinxcontrib.serializinghtml (1.1.5) from d:\anaconda\envs\te_py39\lib\site-packages\sphinxcontrib\serializinghtml\__init__.py
#   sphinxcontrib.qthelp (1.0.3) from d:\anaconda\envs\te_py39\lib\site-packages\sphinxcontrib\qthelp\__init__.py
#   alabaster (0.7.12) from d:\anaconda\envs\te_py39\lib\site-packages\alabaster\__init__.py
#   sphinx_rtd_theme (unknown version) from d:\anaconda\envs\te_py39\lib\site-packages\sphinx_rtd_theme\__init__.py
#   sphinx.ext.todo (4.1.0) from d:\anaconda\envs\te_py39\lib\site-packages\sphinx\ext\todo.py
#   sphinx.ext.viewcode (4.1.0) from d:\anaconda\envs\te_py39\lib\site-packages\sphinx\ext\viewcode.py
#   sphinx.ext.extlinks (4.1.0) from d:\anaconda\envs\te_py39\lib\site-packages\sphinx\ext\extlinks.py
#   sphinxcontrib.spelling (7.3.2) from d:\anaconda\envs\te_py39\lib\site-packages\sphinxcontrib\spelling\__init__.py
#   myst_parser (0.17.0) from d:\anaconda\envs\te_py39\lib\site-packages\myst_parser\__init__.py
Traceback (most recent call last):
  File "d:\anaconda\envs\te_py39\lib\site-packages\sphinx\cmd\build.py", line 280, in build_main
    app.build(args.force_all, filenames)
  File "d:\anaconda\envs\te_py39\lib\site-packages\sphinx\application.py", line 337, in build
    self.builder.build_all()
  File "d:\anaconda\envs\te_py39\lib\site-packages\sphinx\builders\__init__.py", line 257, in build_all
    self.build(None, summary=__('all source files'), method='all')
  File "d:\anaconda\envs\te_py39\lib\site-packages\sphinx\builders\__init__.py", line 360, in build
    self.finish()
  File "d:\anaconda\envs\te_py39\lib\site-packages\sphinx\builders\html\__init__.py", line 633, in finish
    self.finish_tasks.add_task(self.copy_static_files)
  File "d:\anaconda\envs\te_py39\lib\site-packages\sphinx\util\parallel.py", line 49, in add_task
    res = task_func()
  File "d:\anaconda\envs\te_py39\lib\site-packages\sphinx\builders\html\__init__.py", line 813, in copy_static_files
    context.update(self.indexer.context_for_searchtool())
  File "d:\anaconda\envs\te_py39\lib\site-packages\sphinx\search\__init__.py", line 427, in context_for_searchtool
    'search_language_stemming_code': self.get_js_stemmer_code(),
  File "d:\anaconda\envs\te_py39\lib\site-packages\sphinx\search\__init__.py", line 453, in get_js_stemmer_code
    language_js = js_file.read()
  File "d:\anaconda\envs\te_py39\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 152: character maps to <undefined>