Accented chars Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Clocloc
Posts: 7
Joined: 10 Jan 2021, 10:48

Accented chars

Post by Clocloc » 19 Jan 2021, 08:51

Hello,

I have a problem dealing with accented characters on Windows 10.
I have 2 PC: one running IE 11 and Windows 8.1, the other one running IE 11 and Windows 10 latest version
What I'm doing is to go to a specified URL, retrieve all the page links, search for a specifically labelled link and display the URL (the href). And I'm using COM objects of course
So, the code is pretty easy:

Code: Select all

IE := ComObjCreate("InternetExplorer.Application")
IE.Navigate(https epyon.pagesperso-orange.fr /test1.html"  Broken Link for safety ")
IE.Visible := true
While IE.Busy
Sleep, 100
Links := IE.Document.Links
Loop % links.length {
	if (links[A_Index - 1].innerText = "Lala tété") ; looking for the URL which label is "Lala tété"
	{
		foundUrl := links[A_Index - 1].href
		MsgBox, %foundUrl%
		break
	}
}
This script works like a charm on the Win 8.1 computer. But there's no way for it to work on the W10 PC. It doesn't display the message box. I tried to debug and figured out a "workaround".
Instead of strictly matching strings, I will use IfInString to do a partial match. So the new loop code would look like this:

Code: Select all

Loop % links.length {
	link_text := links[A_Index - 1].innerText
	search_text := "Lala"
	IfInString link_text, %search_text%
	{
		foundUrl := links[A_Index - 1].href
		MsgBox, %foundUrl%
		break
	}
}
That modified script does work on both PC, yay. That makes me suspect the special chars proceessing. Since the label I search has a "é" (a char with accent), I guess there might be something not working in W10, contrary to W8.1
Do you have any idea why, and how to make it work the way it should when a label has special accented characters?
Thanks in advance

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

Re: Accented chars  Topic is solved

Post by mikeyww » 19 Jan 2021, 08:55

Is the AHK script file saved in UTF-8 with BOM signature?

Clocloc
Posts: 7
Joined: 10 Jan 2021, 10:48

Re: Accented chars

Post by Clocloc » 19 Jan 2021, 09:17

Wow, I never heard about that BOM signature thing. I did some quick search about it and followed your advice. I converted the script from ANSI into UTF8 and it works well now. I tried both UTF8 no BOM and UTF8 BOM and both did the job. Thank you very much! I've learnt a simple but great tip today! :D

garry
Posts: 2630
Joined: 22 Dec 2013, 12:50

Re: Accented chars

Post by garry » 19 Jan 2021, 09:28

I use notepad and save as... UTF-8 with BOM

Post Reply

Return to “Ask For Help”