CHR codes from 128 to 159 decimal not working
- JoeWinograd
- Posts: 2198
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
CHR codes from 128 to 159 decimal not working
Version 1.1.14.03 on W7
Seems that AHK does not handle CHR codes from 128 to 159 decimal. I started out wanting to put the trademark symbol (153) in a message box (and a text file) and it showed up as a blank. But the copyright symbol (169) and registered trademark symbol (174) both worked fine. So I tested others and determined that the characters from 128 through 159 display (and append to files) as a blank. Any thoughts on how to fix this? Thanks, Joe
Seems that AHK does not handle CHR codes from 128 to 159 decimal. I started out wanting to put the trademark symbol (153) in a message box (and a text file) and it showed up as a blank. But the copyright symbol (169) and registered trademark symbol (174) both worked fine. So I tested others and determined that the characters from 128 through 159 display (and append to files) as a blank. Any thoughts on how to fix this? Thanks, Joe
Re: CHR codes from 128 to 159 decimal not working
Using Unicode the trademark character is 0x2122. -> Chr(0x2122)
Try running this script with Unicode and ANSI versions of AHK to see the difference:
Try running this script with Unicode and ANSI versions of AHK to see the difference:
Code: Select all
Out := "0`t"
Loop, 256
Out .= Chr(A_Index - 1) (Mod(A_Index, 10) ? " " : "`r`n" A_Index "`t")
FileAppend, % "This script is running with " (A_IsUnicode ? "a Unicode" : "an ANSI") " version of AHK.`r`n`r`n" Out
, % FileName := A_ScriptDir "\Chr_" (A_IsUnicode ? "Unicode" : "ANSI") "_" A_Now ".txt"
Run, % FileName
Re: CHR codes from 128 to 159 decimal not working
probably has something to do with the difference between the normal ANSI charset and Windows 1252 codepage:
http://en.wikipedia.org/wiki/ISO/IEC_8859-1
http://en.wikipedia.org/wiki/Windows-1252
See the green boxes in the Windows 1252 codepage. They don't exist in other encodings.
http://en.wikipedia.org/wiki/ISO/IEC_8859-1
http://en.wikipedia.org/wiki/Windows-1252
See the green boxes in the Windows 1252 codepage. They don't exist in other encodings.
The Windows-1252 codepage coincides with ISO-8859-1 for all codes except the range 128 to 159 (hex 80 to 9F), where the little-used C1 controls are replaced with additional characters including all the missing characters provided by ISO-8859-15. Code page 28591 aka Windows-28591 is the actual ISO-8859-1 codepage.[1]
- JoeWinograd
- Posts: 2198
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: CHR codes from 128 to 159 decimal not working
Thanks for the reply, Kon. I ran it on my Unicode install and it does not show 128-159. I don't have an ANSI install to test it on (and I'd rather not do an uninstall/reinstall...twice), but I see your point. Regards, Joe
- JoeWinograd
- Posts: 2198
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: CHR codes from 128 to 159 decimal not working
guest3456,
Thanks for the reply - much appreciated. Regards, Joe
Thanks for the reply - much appreciated. Regards, Joe
Re: CHR codes from 128 to 159 decimal not working
Just an FYI, if you used the installer to install AHK you probably have the ANSI .exe file in the AHK Program Files folder already. No uninstall/reinstall required. The installer just picks the default version of AHK to use, but both should be present.JoeWinograd wrote:I ran it on my Unicode install and it does not show 128-159. I don't have an ANSI install to test it on (and I'd rather not do an uninstall/reinstall...twice)
Try right clicking a script > Open With > AutoHotkey ANSI 32-Bit
Or you could download just the ANSI .exe file from the downloads page, then drag and drop the script onto the .exe.
- JoeWinograd
- Posts: 2198
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: CHR codes from 128 to 159 decimal not working
kon,
Thanks for that explanation - I do have the ANSI 32-bit EXE in ProgFiles, and running your script with it does, indeed, show the 128-159 symbols that I was expecting. Well done! Thanks very much, Joe
Thanks for that explanation - I do have the ANSI 32-bit EXE in ProgFiles, and running your script with it does, indeed, show the 128-159 symbols that I was expecting. Well done! Thanks very much, Joe
Re: CHR codes from 128 to 159 decimal not working
This chart shows what the Unicode character codes 0x80 to 0xFF mean.
- JoeWinograd
- Posts: 2198
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: CHR codes from 128 to 159 decimal not working
Thanks, lexikos, very helpful. Now if I can just figure out the Boolean search...
Re: CHR codes from 128 to 159 decimal not working
I should have mentioned this before. To make your script show the trademark symbol regardless of whether you are using AHK Unicode or ANSI you could do something like this:
MsgBox, % Chr(A_IsUnicode ? 0x2122 : 0x99)
MsgBox, % Chr(A_IsUnicode ? 0x2122 : 0x99)
Re: CHR codes from 128 to 159 decimal not working
... or use ChrA():
Code: Select all
#NoEnv
I := 31
C := ""
While (++I < 256)
C .= (Mod(A_Index, 16) = 1 ? "`n" : "`t") . ChrA(I)
Gui, Add, Edit, w0 h0
Gui, Add, Edit, xp yp w400 r14 t8, % SubStr(C, 2)
Gui, Show, , Chr(32) - Chr(255)
Return
GuiClose:
GuiEscape:
ExitApp
ChrA(I) {
Static ANSI := 0
If !(A_IsUnicode)
Return Chr(I)
NumPut(I & 0xFF, ANSI, "UChar")
Return StrGet(&ANSI, 1, "CP0")
}
- JoeWinograd
- Posts: 2198
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: CHR codes from 128 to 159 decimal not working
Thanks, kon, worked a charm! Any thoughts on my Boolean search issue?
- JoeWinograd
- Posts: 2198
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: CHR codes from 128 to 159 decimal not working
Hi just me,
Great stuff! Thanks, Joe
Great stuff! Thanks, Joe