Try:
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)
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:
just me wrote: ↑18 Apr 2024, 02:15
Your issue seems to be caused by the fact that SciTE expects UTF-8 but gets ANSI...
Indeed for SciTE my script does not work, sorry for confusion.
The code is modified and works for me properly even in SciTE.