python-docx-template icon indicating copy to clipboard operation
python-docx-template copied to clipboard

Wrong encoding when runned via module

Open netaddict opened this issue 1 year ago • 6 comments

Hi,

when I start docxtpl from the command line as module and my json file contains UTF-8 encoded special characters, they seem to be wrong encoded in the resulting docx.

To reproduce it, simply add a character like "ä" in the tests/templates/module_execute.json file and run the module_execute.py in the tests directory.

netaddict avatar Nov 08 '23 09:11 netaddict

Cannot reproduce the problem by adding "ä", please provide your json file.

elapouya avatar Nov 13 '23 15:11 elapouya

Tested it again on MacOS, seems ok here. Another Test on Windows (x64 Python 3.10.9) failed somewhat (see files attached).

module_execute.json module_execute.docx

netaddict avatar Nov 16 '23 15:11 netaddict

I see the wrong character at your DOCX file but I can't reproduce it. (Python 3.10.13, docxtpl 0.16.5) Moreover I add to JSON chinese characters and some arabic characters. For me all characters are OK.

module_execute.json module_execute.docx

Which version of docxtpl are you using?

SergeyZaykov avatar Nov 20 '23 21:11 SergeyZaykov

Well on another machine (Python 3.11.2, docxtpl 0.16.6) I can reproduce the problem. Nor umlauts letter nor chinese characters nor arabic characters doesn't rendered correctly.

SergeyZaykov avatar Nov 20 '23 22:11 SergeyZaykov

Still cannot reproduce the problem : @SergeyZaykov : please provide .docx template and .json file.

elapouya avatar Jan 03 '24 16:01 elapouya

@elapouya Here are the problematic template and the JSON data.: module_execute.json module_execute_tpl.docx Python 3.11.2 docxtpl 0.16.6

SergeyZaykov avatar Jan 09 '24 18:01 SergeyZaykov