-
Notifications
You must be signed in to change notification settings - Fork 65
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
How can I output Chinese with send? #45
Comments
Hmm. A quick search seems to indicate that AutoHotkey itself does not have great support for unicode. If you are wanting to use the There are some documented workarounds for this in the AHK forums.
If I can find a good workaround for sending unicode that can be cleanly implemented, I'd be happy to add it as a function in the library. |
I think what I'll be planning to do is have a method which will take unicode characters and convert them to the unicode sequences in AHK scripts. E.g. characters like In the meantime, it should be possible to use the ahk.send_input('Hello unicode {U+2F72}') Eventually, maybe the |
ahk.image_search's image path could not use chinese words either will autohotkey_unicode version work for this? and...
could this support encoding arg? |
Yeah, this makes sense. From what I understand, the version of AHK that I test against is already unicode compatible. I've been trying to figure out the behavior of how AHK interprets the encoding sent to it. For instance, when reading from a file, AHK seems to read UTF-8 unicode just fine. When sent via stdin to the subprocess, it seems that there is some sort of encoding mismatch. I suspect a locale or system-default encoding is being used. When sending the following as UTF-8 encoded bytes to the subprocess:
AutoHotkey ends up sending |
Is there some way set global encoding setting for different countries, instead of utf-8 |
What's important is to identify how AHK does encoding detection. I believe it may rely on Windows semantics, which will used the preferred encoding for the locale if the bytes make sense in that encoding. For example you can use So knowing what the preferred encoding is alone may not be enough. I'll have to do some more testing around this and maybe inquire with some folks more knowledgable of Windows/AHK's behavior when reading from stdin. |
(Edit: Oops, didn't realize this was a Python wrapper, this probably won't solve anything, but it might help someone like me who stumbled upon this issue first :) ) Try saving the https://www.reddit.com/r/AutoHotkey/comments/9zz9q3/why_do_hotstrings_sometimes_dont_work_depending/
|
Yeah. Earlier on in this project, the implementation of calling AHK scripts was to write the .ahk script to a temporary file and then call the AHK executable, providing the temp filename as an argument. I think with that earlier implementation, a lot of the unicode stuff wasn't an issue. However, the current implementation is to pass the script text (as bytes) to the AHK process via stdin, avoiding the need to write out the generated script to a file (avoiding things like permissions errors or failing to cleanup tempfiles) For whatever reason, AHK doesn't seem to use UTF-8 when the script text is passed through stdin. 🤷♀️ |
So, the BOM doesn't work when passing script as stdin, but there is a flag to set the codepage, which seems promising. See: #132 |
This should be essentially resolved with #132 One major exception is when using daemon mode. In which case, you must workaround this by using unicode sequences (e.g. |
Hello ~
I want to know how to send out Chinese?
The text was updated successfully, but these errors were encountered: