Can anyone tell me how I can automatically substitute all "xE9" special character ( and other similar ) with another character I want?
I use the SciTE4AutoHotkey editor.
Thank you very much.
InStr(...) gives error?
Re: InStr(...) gives error?
Did these "xE9" characters appear when you changed the file to UTF encoding?
If so, see my previous recommendation about first, creating the file, and then, pasting your code into the file.
Hopefully you saved a back-up before you converted the file. If not, check the folder for a .BAK file, which might have a previous version.
ste(phen|ve) kunkel
Re: InStr(...) gives error?
Your issue seems to be caused by the fact that SciTE expects UTF-8 but gets ANSI. Most single characters above 127 are invalid in UTF-8. Only some are permitted as leading characters of character sequences used to encode a single character. The è is 0xE9/235 and thus invalid UTF-8. SciTE seems to mark invalid characters as xXX using their hex value.
Re: InStr(...) gives error?
Try:
P.s.: Save the script in the folder where you have your Ahk scripts. It will copy all (ANSI & UTF-8) of your scripts (for safety) to subfolder UTF8_Files appending "_UTF-8" to each file name (before ".ahk" extension) and save them as (you guessed it) UTF-8. Script is safe and works for me.
Note:Indeed for SciTE my script does not work, sorry for confusion.
The code is modified and works for me properly even in SciTE.
Code: Select all
#Requires AutoHotkey v2+
#SingleInstance Force
Loop Files, "*.ahk" {
if !FileExist(utf8FilePath:= A_ScriptDir "\" (Utf_Files:= "UTF8_Files") "\" StrReplace(A_LoopFileName, "." A_LoopFileExt) "_UTF-8." A_LoopFileExt) {
ansiContent:= FileRead(A_LoopFileName, "CP1252")
if !DirExist(Utf_Files)
DirCreate Utf_Files
FileAppend ansiContent, utf8FilePath, "UTF-8"
}
If GetKeyState("Esc", "P")
Break
}
SoundBeep(8000), SoundBeep(4000)
Note:
The code is modified and works for me properly even in SciTE.
Last edited by rommmcek on 19 Apr 2024, 17:49, edited 3 times in total.
Re: InStr(...) gives error?
I modified the code above and it seems to solve the issue.