Skip to content

Wrong encoding when runned via module #516

Open
cvas22/docform
#173

Description

@netaddict

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.

Activity

  1. elapouya commented on Nov 13, 2023

    @elapouya
    Owner

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

  2. netaddict commented on Nov 16, 2023

    @netaddict
    Author

    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

  3. SergeyZaykov commented on Nov 20, 2023

    @SergeyZaykov

    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?

  4. SergeyZaykov commented on Nov 20, 2023

    @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.

  5. elapouya commented on Jan 3, 2024

    @elapouya
    Owner

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

  6. SergeyZaykov commented on Jan 9, 2024

    @SergeyZaykov

    @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

  7. dmitriadov commented on Aug 27, 2025

    @dmitriadov

    Same issue for me - any Unicode symbols rendered incorrectly when running via module. I think the issue is in get_json_data - it should open the json file with utf-8 encoding.

  8. added a commit that references this issue on Jul 30, 2026
    286eaf0
  9. cvas22 commented on Nov 22, 2026

    @cvas22

    @netaddict @SergeyZaykov @dmitriadov fyi, this is fixed in Docform (the maintained fork at https://github.com/cvas22/docform, docform on PyPI) with #655 by @davidpavlovschi, merged in cvas22/docform#173. It'll be in the next release.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions