2. make a v1 script that does this (and then test it):
Code: Select all
file := A_Scriptdir "\你好.txt"
run, % file
Code: Select all
file := A_Scriptdir "\你好.txt"
run file
Code: Select all
file := A_Scriptdir "\你好.txt"
run, % file
Code: Select all
file := A_Scriptdir "\你好.txt"
run file
Saving as UTF-8 and UTF-8-BOM made no difference in the result. It worked in V1 and not in V2.
It shows a msgbox in v2 with this:HakitoJin wrote: ↑09 Apr 2019, 09:05When notepad++ saves a file as UTF-8, there is literally no difference between that file, and the same file saved as ANSI.
So autohotkey loads the UTF-8 file as ANSI, because there is no way to distinguish it (no idea why your ahk1 loads it as UTF-8 though).
Also, when you save the same file as UTF-8 in normal notepad, it actually uses UTF-8-BOM, which adds a character at the very start of the file.
Here is a comparison between the same file in different formats: i.imgur.com/kpYuK3A.jpg
All you need to test this is: msgbox "你好"
---------------------------
v2.ahk2
---------------------------
ä½ å¥½
---------------------------
OK
---------------------------
This is my registry value there:HakitoJin wrote: ↑09 Apr 2019, 09:05
Update:
I think your autohotkey v1 registry file association cmd might have /CP65001 as a parameter, which tells it to use UTF-8 by default.
Go check if the default value in HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Open\Command has it.
It might look a little something like this "C:\Program Files\AutoHotkey\AutoHotkey.exe" /CP65001 "%1" %*
---------------------------
v2.ahk2
---------------------------
Error: Failed attempt to launch program or document:
Action: <C:\ahk\ä½ å¥½.txt>
Params: <>
Specifically: The system cannot find the file specified.
Line#
002: file := A_ScriptDir "\ä½ å¥½.txt"
---> 003: run(A_ScriptDir "\ä½ å¥½.txt")
004: Exit
005: Exit
005: Exit
The current thread will exit.
---------------------------
OK
---------------------------