-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
Problem with encoding Polish characters in shell #1749
Comments
This may be the same issue as #1736. |
This is definitely a sticky issue with how the various operating systems Espanso passes characters to parse those characters. I have a Windows 10 machine running Espanso 2.1.8 (US english installation) and tried to replicate and try to see if I could get the characters to render as intended. What I tried:
Unsure if there is a specific solution to this at the moment, given that Espanso is 'at the mercy' of the operating system to recognize characters properly and Windows seems to be the one out of the three supported OSes that has this issue the most. |
This is not an espanso bug, IMO. Espanso uses UTF8 (probably, or the encoding of the yaml file is used ?), so the shell console should be configured to work with UTF8. Here is how you can do this with posershell (the default shell used by espanso on Windows). - trigger: ":pl"
replace: "{{output}}"
vars:
- name: output
type: shell
params:
cmd: "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; echo 'ąśα'" or if you accept to use wsl as shell you can simply do - trigger: ":pl"
replace: "{{output}}"
vars:
- name: output
type: shell
params:
cmd: "echo 'ąśα'"
shell: wsl In both cases the output is as expected |
Thanks @kpym, Your solution for PS worked. Do you perhaps have a suggestion on how to do this for Python scripts? My example was a simplification of my problem. In reality, I am calling scripts in which - trigger: ";;"
replace: "{{output}}"
vars:
- name: output
type: script
params:
args:
- python
- "%CONFIG%/scripts/script.py" the print("ąś") |
So your problem is not with the consol encoding at all, because you are using I have not checked, but probably your import sys
def print_utf8(s):
sys.stdout.buffer.write(s.encode('utf8'))
print_utf8("ąśα❤") |
For the Python this works well:
|
returns
��
The problem occurs when I use Python. In my script, I retrieve data from the clipboard, transform it, and return it to espanso through print(). To simplify the problem, I have reduced it to above example.
Setup information
The text was updated successfully, but these errors were encountered: