Save file as UTF-8

Share your ideas as to how the documentation can be improved.
need4speed
Posts: 143
Joined: 22 Apr 2016, 06:50

Save file as UTF-8

31 Jul 2020, 03:36

The line
Be sure to save the file as UTF-8 with BOM if it will contain non-ASCII characters. For details, see the FAQ.
should be changed to
Be sure to save the file as UTF-8 if it will contain non-ASCII characters. For details, see the FAQ.
Reason:
in the FAQ UTF-8 is recommend:
Short answer: Save the script as UTF-8.
Also in Win10 this is the standard encoding settings for Editor/Notepad, this applies to other Notepad clones as well.
TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Save file as UTF-8

31 Jul 2020, 18:42

It’s the faq that is out of date, actually. (Well, the v1 faq is correct but the v2 faq is not.)

When a Unicode file is saved with BOM this gives certainty that the file is Unicode. Otherwise software accessing the file has to guess what encoding was used when the file was written. And the trouble with guessing is that it sometimes gets it wrong.

So always save your Unicode files with BOM to avoid encoding problems.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: Save file as UTF-8

01 Aug 2020, 00:25

My recommendation for AutoHotkey v1 is still UTF-8 with BOM. UTF-8 without BOM will not work without the /cp65001 command line switch, such as with portable AutoHotkey.exe or without the UTF-8 option enabled in the installer.

The top line of the FAQ does not specify with or without BOM. In all but the most recent versions of Notepad, UTF-8 with BOM is just "UTF-8", and ANSI is the default. AutoHotkey does not exclusively run on the latest Windows 10 builds. Further down the FAQ says "To save as UTF-8 in Notepad, select UTF-8 or UTF-8 with BOM from the Encoding drop-down in the Save As dialog", but either option could include a BOM, depending on the Notepad version.

@TAC109, in what way is the FAQ out of date, or incorrect for v2?
TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Save file as UTF-8

01 Aug 2020, 05:29

@lexikos The faq entries are different between v1 and v2, but on further reading I see that AutoHotkey v2 defaults to UTF-8 for script files so saving them as UTF-8 with BOM is not so important in this case.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
need4speed
Posts: 143
Joined: 22 Apr 2016, 06:50

Re: Save file as UTF-8

03 Aug 2020, 07:35

"AutoHotkey does not exclusively run on the latest Windows 10 builds" is true, but as Win7 development ceased and support has been discontinued, Win10 will be sooner or later the dominant desktop OS.
I think the statement in v2 Help
Be sure to save the file as UTF-8 with BOM if it will contain non-ASCII characters. For details, see the FAQ.
is confusing. As "UTF-8" is already the standard preset eg. in Editor, is it really recommendable in v2 to manually change it to UTF-8 with BOM?
In certain circumstances "UTF-8 with BOM" can cause trouble.
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: Save file as UTF-8

03 Aug 2020, 21:47

I think users of Windows 7, 8, 8.1, older 10 builds and editors that do not default to UTF-8 will not appreciate your point of view. You don't need to understand the recommendation to benefit from following it.

The "circumstances" you mention are irrelevant to AutoHotkey scripts. Under more relevant circumstances, not following the recommendation will cause problems.

Return to “Suggestions on Documentation Improvements”

Who is online

Users browsing this forum: No registered users and 11 guests