Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The inclusion of Chinese characters in the Script Extension will result in garbled text #1698

Closed
Autumn-one opened this issue Sep 7, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Autumn-one
Copy link

Describe the bug
All the Chinese parts included in Python scripts are garbled

To Reproduce
Matching configuration is as follows

matches:
    -   trigger: ":py"
        replace: "{{output}}"
        vars:
            -   name: output
                type: script
                params:
                    args:
                        -   python
                        -   "%CONFIG%/scripts/scripts.py"

scripts.py The contents are as follows

import sys

if __name__ == "__main__":
    print(f"python 脚本参数:{sys.argv}")

Screenshots
image

Logs
If possible, run espanso log in a terminal after the bug has occurred, then post the output here so that we can better diagnose the problem

Setup information

  • OS: What OS are you using?
  • Version: which version of Espanso are you running? (you can find out by running espanso --version inside a terminal)
  • windows11 espanso 2.1.8
@Autumn-one Autumn-one added the bug Something isn't working label Sep 7, 2023
@kpym
Copy link

kpym commented Dec 17, 2023

This issue is identical to #1749. This is not an expanso bug, but the way your python script produce the output. Check my answer.

Try the following scripts.py

import sys

def print_utf8(s):
    sys.stdout.buffer.write(s.encode('utf8'))

if __name__ == "__main__":
    print_utf8(f"python 脚本参数:{sys.argv}")

@Autumn-one
Copy link
Author

This issue is identical to #1749. This is not an expanso bug, but the way your python script produce the output. Check my answer.

Try the following scripts.py

import sys

def print_utf8(s):
    sys.stdout.buffer.write(s.encode('utf8'))

if __name__ == "__main__":
    print_utf8(f"python 脚本参数:{sys.argv}")

Thank you very much, the solution you provided does work!

@Autumn-one
Copy link
Author

The problem has been solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants