YaLafi icon indicating copy to clipboard operation
YaLafi copied to clipboard

YaLaFi insists in using \Lib\encodings\cp1252.py even in a UTF-8 environment

Open csrabak opened this issue 1 year ago • 0 comments

In a Windows 10, home ed, single language in a CMD shell, where: C:\>chcp Página de código ativa: 65001

I.e., UTF-8 code page.

When running this per example command line: py -3 -m yalafi.shell --server lt --output plain --encoding UTF-8 --language pt-BR text.tex > reslts.text

I get:

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:\Python\Python311\Lib\site-packages\yalafi\shell\__main__.py", line 3, in <module>
    from yalafi.shell import shell
  File "C:\Python\Python311\Lib\site-packages\yalafi\shell\shell.py", line 376, in <module>
    gentext.generate_text_report(proofreader.run_proofreader, sys.stdout)
  File "C:\Python\Python311\Lib\site-packages\yalafi\shell\gentext.py", line 92, in generate_text_report
    output_text_report(tex, plain, charmap, matches, file, out)
  File "C:\Python\Python311\Lib\site-packages\yalafi\shell\gentext.py", line 55, in output_text_report
    out.write('Suggestion: ' + repls + '\n')
  File "C:\Python\Python311\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u2082' in position 13: character maps to <undefined>

Which I cannot understand why YaLaFi "prefers" the CP1252 encoding even if told via command line and the shell in UTF-8!

Is there some way to parametrize YaLaFi to avoid this issue?

csrabak avatar Aug 03 '24 17:08 csrabak