Input Unicode character

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
RBBD
Posts: 20
Joined: 09 Apr 2021, 15:09

Input Unicode character

Post by RBBD » 03 Dec 2022, 08:45

What is the best way to input a Unicode character with AHK?

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Input Unicode character

Post by mikeyww » 03 Dec 2022, 08:59

Code: Select all

InputBox, char, Character, Enter a character.,, 300, 125
MsgBox, %char%

RBBD
Posts: 20
Joined: 09 Apr 2021, 15:09

Re: Input Unicode character

Post by RBBD » 03 Dec 2022, 09:10

As this is an uncommon Unicode Char how do I tell AHK what it is?

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Input Unicode character

Post by mikeyww » 03 Dec 2022, 09:13

A faster way to an answer is to give the reader an example of the problem. What character is it?

RBBD
Posts: 20
Joined: 09 Apr 2021, 15:09

Re: Input Unicode character

Post by RBBD » 03 Dec 2022, 09:18

It will vary, but one would be U+014D - ō

User avatar
boiler
Posts: 16771
Joined: 21 Dec 2014, 02:44

Re: Input Unicode character

Post by boiler » 03 Dec 2022, 09:21

One way is to make a hotkey:

Code: Select all

+^o::Send, ō ; press Shift+Ctrl+o

Make sure your script file is saved with “UTF-8 with BOM” encoding.

RBBD
Posts: 20
Joined: 09 Apr 2021, 15:09

Re: Input Unicode character

Post by RBBD » 03 Dec 2022, 09:33

I am getting ō , not ō The square shows in NP++ as Black background RI
I added your line to a script that enters into notepad++

RBBD
Posts: 20
Joined: 09 Apr 2021, 15:09

Re: Input Unicode character

Post by RBBD » 03 Dec 2022, 09:39

Sorry, just saw this:
"Make sure your script file is saved with “UTF-8 with BOM” encoding."

Could you help me with that please?

RBBD
Posts: 20
Joined: 09 Apr 2021, 15:09

Re: Input Unicode character

Post by RBBD » 03 Dec 2022, 09:42

I found UTF-8-BOM in NP++ , but it looks the same

RBBD
Posts: 20
Joined: 09 Apr 2021, 15:09

Re: Input Unicode character

Post by RBBD » 03 Dec 2022, 09:44

If I copy the char from Character Map it works fine.
However I was hoping to automate the process

User avatar
boiler
Posts: 16771
Joined: 21 Dec 2014, 02:44

Re: Input Unicode character

Post by boiler » 03 Dec 2022, 09:46

Close the script in your editor after saving it with the new encoding, then open it again, especially if you’re using a feature to run it directly from the editor.

Are you using the the ANSI or Unicode version of AHK? If you’re not sure, run the following script:

Code: Select all

MsgBox, % A_IsUnicode ? "Unicode" : "ANSI"

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Input Unicode character

Post by mikeyww » 03 Dec 2022, 09:47

It worked here.

image221203-0947-001_cr.png
Output
image221203-0947-001_cr.png (21.94 KiB) Viewed 808 times

AHK version 1.1.36.01

RBBD
Posts: 20
Joined: 09 Apr 2021, 15:09

Re: Input Unicode character

Post by RBBD » 03 Dec 2022, 10:01

It show unicode and my version 1.1.33.10

sofista
Posts: 645
Joined: 24 Feb 2020, 13:59
Location: Buenos Aires

Re: Input Unicode character

Post by sofista » 03 Dec 2022, 10:23

RBBD wrote:
03 Dec 2022, 09:42
I found UTF-8-BOM in NP++ , but it looks the same
A common misconception in Notepad++ is to use Encoding > UTF-8-BOM instead of Encoding > Convert to UTF-8-BOM. The first command changes only the display of the characters, while the second, the recommended for what you want to accomplish, changes the file.

RBBD
Posts: 20
Joined: 09 Apr 2021, 15:09

Re: Input Unicode character

Post by RBBD » 03 Dec 2022, 10:28

Still not right. I could try getting up to your version.
Attachments
NPchar.jpg
NPchar.jpg (22.83 KiB) Viewed 749 times
image.png
image.png (20.28 KiB) Viewed 749 times

sofista
Posts: 645
Joined: 24 Feb 2020, 13:59
Location: Buenos Aires

Re: Input Unicode character

Post by sofista » 03 Dec 2022, 10:31

RBBD wrote:
03 Dec 2022, 10:28
Still not right. I could try getting up to your version.
As I understand, new 2 is not saved to disk. Please, do it.

Edit: Also check this option: Settings > Preferences... > MISC. > Use DirectWrite (May improve rendering special characters, need to restart Notepad++)
Last edited by sofista on 03 Dec 2022, 10:37, edited 1 time in total.

RBBD
Posts: 20
Joined: 09 Apr 2021, 15:09

Re: Input Unicode character

Post by RBBD » 03 Dec 2022, 10:36

Saved, checked encoding, reloaded
Attachments
MacronO.jpg
MacronO.jpg (26 KiB) Viewed 732 times

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Input Unicode character

Post by mikeyww » 03 Dec 2022, 10:38

It's possible that the AHK script file needs to be in that format (boiler has already noted).

User avatar
boiler
Posts: 16771
Joined: 21 Dec 2014, 02:44

Re: Input Unicode character

Post by boiler » 03 Dec 2022, 10:42

Yes, AHK doesn’t know or care what mode you are using to display it in your editor. The only thing that matters is that the script file is saved with that encoding.

RBBD
Posts: 20
Joined: 09 Apr 2021, 15:09

Re: Input Unicode character

Post by RBBD » 04 Dec 2022, 07:11

Thanx, much appreciated! That was the answer.
Sorry for the delay. Our internet went down. High winds & power losses around here.
This is a great help. All the best to you.

Post Reply

Return to “Ask for Help (v1)”