Ansi VS Unicode

Get help with using AutoHotkey and its commands and hotkeys
User avatar
DataLife
Posts: 239
Joined: 29 Sep 2013, 19:52

Ansi VS Unicode

22 May 2018, 15:18

The code below retrieves all networks that have been connected to the computer since windows was installed.
I install Ansi Autohotkey and compile and a user in Sweden gets this...notice the ?? network names.
https://www.dropbox.com/s/jm8500soxijw7ks/Ansi.PNG?dl=0

When install Unicode Autohotkey and compile the user in Sweden gets this...
https://www.dropbox.com/s/806qj9j9uqj7g4s/Unicode.PNG?dl=0

How can I get this to display the network names properly?
thanks
DataLife


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Check out my scripts. (MyIpChanger) (XPSnap) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
TLM
Posts: 1289
Joined: 01 Oct 2013, 07:52

Re: Ansi VS Unicode

22 May 2018, 17:55

Sweet Class ID :D!!!

I'm not 100% how but I'm thinking setting the encoding for the returned pointer may be what you're after.

Code: [Select all] [Download] GeSHi © Codebox Plus

	ptr := INetwork.GetName()
NetworkName := StrGet( &ptr, StrLen( ptr ), "UTF-16" )
Again this is just a guess but I wasn't able to find a comparable encoding property on MSDN

If you don't mind me asking, what header did you find that Class ID in? Thanks ;)

edit: After doing some more research, I don't think that using the pointer will work... It seems like it has to do with how the script is compiled..
exams.. :headwall:
User avatar
DataLife
Posts: 239
Joined: 29 Sep 2013, 19:52

Re: Ansi VS Unicode

22 May 2018, 19:40

TLM wrote:Sweet Class ID :D!!!

I'm not 100% how but I'm thinking setting the encoding for the returned pointer may be what you're after.

Code: [Select all] [Download] GeSHi © Codebox Plus

	ptr := INetwork.GetName()
NetworkName := StrGet( &ptr, StrLen( ptr ), "UTF-16" )
Again this is just a guess but I wasn't able to find a comparable encoding property on MSDN

If you don't mind me asking, what header did you find that Class ID in? Thanks ;)

edit: After doing some more research, I don't think that using the pointer will work... It seems like it has to do with how the script is compiled..

I got the code from HotKeyIt from https://autohotkey.com/boards/viewtopic ... 316#p77824

If the issue is how it is compiled, do you have any suggestions? I use Ahk2Exe.exe. The properties for Ahk2Exe.exe say the file version is 1.1.28.2 and the product version is 1.1.28.02 - Size 838 KB
Ahk2Exe.exe is located in C:\Program Files\AutoHotkey\Compiler

thanks
DataLife
Check out my scripts. (MyIpChanger) (XPSnap) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
TLM
Posts: 1289
Joined: 01 Oct 2013, 07:52

Re: Ansi VS Unicode

22 May 2018, 19:49

:think: I've been trying to reproduce the issue on different AHk installations and systems but I always get the correct encoding regardless :eh:
I was thinking maybe the Transform command but then that's not available in Unicode ... Anyway i'll report back if I get it to `not` work lol
exams.. :headwall:
User avatar
DataLife
Posts: 239
Joined: 29 Sep 2013, 19:52

Re: Ansi VS Unicode

22 May 2018, 19:58

TLM wrote::think: I've been trying to reproduce the issue on different AHk installations and systems but I always get the correct encoding regardless :eh:
I was thinking maybe the Transform command but then that's not available in Unicode ... Anyway i'll report back if I get it to `not` work lol

I always get the correct output also. The issue happens with the user in Sweden.

I read somewhere that I can create another windows account on my computer and change the language to Swedish. I could have this code on the desktop that way I can find it easily for testing to see if I can reproduce the issue.
Check out my scripts. (MyIpChanger) (XPSnap) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
DataLife
Posts: 239
Joined: 29 Sep 2013, 19:52

Re: Ansi VS Unicode

26 May 2018, 13:06

@TLM
In my research I found this.... https://autohotkey.com/board/topic/1594 ... ntry103569

It mentions Ansi2Unicode and Unicode2Ansi. I do not understand any of it. Could this fix the display issue?

As I said before this only happens when the end user in Sweden runs the compiled script in the first post. He is not an Authokey user.
So I am not able to experiment to find out how to use Ansi2Unicode and know if my experimentation is correctly coded or if it is correctly coded if it works in Sweden. Once I come up with an attempt to fix the display issue I send the compiled script to the end user for testing.

thanks
Robert
Check out my scripts. (MyIpChanger) (XPSnap) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
TLM
Posts: 1289
Joined: 01 Oct 2013, 07:52

Re: Ansi VS Unicode

26 May 2018, 14:56

Perhaps but I started thinking maybe you need to make an API call to a language function that would switch it over ( and back if necessary ) for your script.
I'd try both ( or any other possible solution ).. BTW Switching TO Swedish didn't result in the same output for me :/ ...
exams.. :headwall:
User avatar
DataLife
Posts: 239
Joined: 29 Sep 2013, 19:52

Re: Ansi VS Unicode

26 May 2018, 17:30

I do not know how to make an API call. Is it something that can be learned easily? What is the skill level dealing with API? Easy, Medium, Hard. I will do some research on "API call to a language function" to see what I find.
Check out my scripts. (MyIpChanger) (XPSnap) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
TLM
Posts: 1289
Joined: 01 Oct 2013, 07:52

Re: Ansi VS Unicode

27 May 2018, 12:58

DllCall() to a windows api function can have a steep learning curve but It's ok as there's usually an existing library for such things ;)
Try this one: Default Keyboard Lang
exams.. :headwall:
User avatar
DataLife
Posts: 239
Joined: 29 Sep 2013, 19:52

Re: Ansi VS Unicode

09 Jun 2018, 05:20

I still have not found a solution to this issue.

The code below retrieves all networks that have been connected to the computer since windows was installed.
I installed Ansi Autohotkey and compiled and a user in Sweden gets this...notice the ?? network names.
https://www.dropbox.com/s/jm8500soxijw7ks/Ansi.PNG?dl=0

When install Unicode Autohotkey and compile the user in Sweden gets this...
https://www.dropbox.com/s/806qj9j9uqj7g ... e.PNG?dl=0

One suggestion was making an API call. At the moment that is above my coding skill.

Does anyone know of another way to get a list of all networks that Windows has connected previously?

thanks
Robert

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Check out my scripts. (MyIpChanger) (XPSnap) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
jeeswg
Posts: 4504
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Ansi VS Unicode

09 Jun 2018, 05:26

Did you try this?
[COM] How to enumerate IEnumNetworkConnections in a more "native" way? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=15316&p=220527#p220527
User avatar
DataLife
Posts: 239
Joined: 29 Sep 2013, 19:52

Re: Ansi VS Unicode

10 Jun 2018, 12:34

I completely overlooked your reply on the other thread. I will try that when I get home later today.
Thanks
Datalife
Check out my scripts. (MyIpChanger) (XPSnap) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
DataLife
Posts: 239
Joined: 29 Sep 2013, 19:52

Re: Ansi VS Unicode

10 Jun 2018, 18:38

I was not sure if this issue was a display issue or an issue retrieving network names. That is why this issue is being covered on this thread and at https://autohotkey.com/boards/viewtopic ... 26#p223226

I now believe the issue is a display issue.

I have always used Ansi 32bit and Scite4Autohotkey.

When I compiled my code as Unicode all I did was install the Unicode version of AutoHotkey and then compile. Should I have saved my script as Unicode or UTF8 before compiling with the Unicode version of Autohotkey?
thanks
Datalife
Check out my scripts. (MyIpChanger) (XPSnap) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
Masonjar13
Posts: 1333
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Ansi VS Unicode

11 Jun 2018, 03:02

DataLife wrote:When I compiled my code as Unicode all I did was install the Unicode version of AutoHotkey and then compile. Should I have saved my script as Unicode or UTF8 before compiling with the Unicode version of Autohotkey?

Unicode AHK requires UTF-8 files that have a BOM.
User avatar
DataLife
Posts: 239
Joined: 29 Sep 2013, 19:52

Re: Ansi VS Unicode

13 Jun 2018, 11:03

I had my user in Sweden exports his Network Profiles from the registry. It appears to be Korean Profile names and descriptions. Google translate detected it as Korean but could not translate to english.

Is this an issue with his computer not be able to display Korean characters?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Check out my scripts. (MyIpChanger) (XPSnap) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
TLM
Posts: 1289
Joined: 01 Oct 2013, 07:52

Re: Ansi VS Unicode

13 Jun 2018, 13:22

ahh I see you're making progress..
exams.. :headwall:
User avatar
DataLife
Posts: 239
Joined: 29 Sep 2013, 19:52

Re: Ansi VS Unicode

13 Jun 2018, 16:34

TLM wrote:ahh I see you're making progress..

The code rather it was Ansi or Unicode was working properly. I just did not figure out it was displaying Korean.

This guy bought his computer from Dell and he has no connections to Korea.

Why is there Korean language in his registry? Any Ideas?
Check out my scripts. (MyIpChanger) (XPSnap) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
just me
Posts: 5397
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Ansi VS Unicode

14 Jun 2018, 02:15

The registry entries contain dates and times stored as SYSTEMTIME structures:

Code: [Select all] [Download] GeSHi © Codebox Plus

typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME;

That might provide a hint.

1. Entry ("癠뷝Ȉ"):

Code: [Select all] [Download] GeSHi © Codebox Plus

"DateCreated"=hex:e2,07,01,00,02,00,02,00,0d,00,29,00,0b,00,b6,01
07E2|0001|0002|0002|000D|0029|000B|01B6
2018|01 |02 |02 |13 |41 |11 |438

2018-01-02 13:41:11

2. Entry ("궛翽"):

Code: [Select all] [Download] GeSHi © Codebox Plus

"DateCreated"=hex:e1,07,0c,00,05,00,16,00,12,00,2f,00,3b,00,7d,01
07E1|000C|0005|0016|0012|002F|003B|017D
2017|12 |05 |16 |18 |47 |59 |381

2017-12-16 18:47:59
User avatar
DataLife
Posts: 239
Joined: 29 Sep 2013, 19:52

Re: Ansi VS Unicode

14 Jun 2018, 06:44

Google translate detects some of them as Korean and some as Chinese but could not translate to English. I may post a request for someone from China or Korea to confirm that this Chinese or Korean.

My user in Sweden has gone on vacation for 2 weeks so I can not ask him about the dates until then.
Check out my scripts. (MyIpChanger) (XPSnap) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
lexikos
Posts: 5939
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Ansi VS Unicode

14 Jun 2018, 20:04

I think just me is hinting that it is not Korean text, but other binary data which coincides with the bit patterns normally used to encode Korean text.

Masonjar13 wrote:Unicode AHK requires UTF-8 files that have a BOM.
Unicode and ANSI versions of AutoHotkey have exactly the same requirements for script file encoding; UTF-8 is recommended, but not required by either version. How the file must be encoded depends on the textual data (source code) of the script, not the version of the executable. All current AutoHotkey versions accept text files ...
  • containing only ASCII source code, with neither UTF-8 nor other non-ASCII characters.
  • encoded as UTF-8 with BOM.
  • encoded as UTF-8 without BOM - or any other codepage - provided that the correct codepage is specified on the command line.
  • encoded as ANSI (specifically, the system's current ANSI codepage) when no BOM is present and no codepage is specified on the command line.
I think the same is true for the current version of Ahk2Exe. Each source file may have a different encoding, as Ahk2Exe automatically converts the source code to UTF-8 for embedding in the compiled script exe.

If the file worked with the ANSI version of AutoHotkey (i.e. characters in the source code were read/decoded correctly), then it should be read correctly by the Unicode version of AutoHotkey, without any changes. If there are issues or differences in behaviour, it is not due to how the script source file is encoded.

However, a file which works with the Unicode version might not work with the ANSI version; not because of the file encoding, but because the source code contains characters which cannot be represented in the current ANSI code page.

COM methods such as INetwork.GetName() always return strings as BSTR (UTF-16 preceded by the string's length). The text part of the BSTR is either retrieved as-is (as UTF-16), or automatically converted to ANSI (in ANSI versions of AutoHotkey). For ANSI versions, any characters which cannot be represented in the current ANSI code page are replaced with '?', and the original characters cannot be retrieved because the data is not present in the string the script receives.

Return to “Ask For Help”

Who is online

Users browsing this forum: AutoHotKeyFan, elkym, eptesicus, rscott and 25 guests