Delphi Galileo IDE (version 8 and up): Force files to be saved as UTF8 – The Oracle at Delphi
Posted by jpluimers on 2019/07/04
Though formatting mangled the registry key to add, the article is interesting: since 2003 (C# Builder 1), you can force the IDE to always save files as UTF8 which should alleviate a lot of encoding problems.
It beats me why this isn’t the default setting, but below is an example .reg file for Delphi 8 which should be easily transformed to more recent Delphi versions:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
[HKEY_CURRENT_USER\Software\Borland\BDS\2.0\Editor] | |
"DefaultFileFilter"="Borland.FileFilter.UTF8ToUTF8" |
So basically (if formatting is kept), you browse to this key (replace Borland with the company for your specific Delphi version, and replace 2.0 by your IDE version):
HKEY_CURRENT_USER\Software\Borland\BDS\16.0\Editor
Then you add a new string value named DefaultFileFilter
with value Borland.FileFilter.UTF8ToUTF8
More background [WayBack] The Oracle at Delphi: More IDE secrets – UTF8 and the Editor
The unmangled registry key (and more tips) was from [WayBack] BSC Polska: Hidden possibilities of Delphi 8.
Get the list of HKEY_CURRENT_USER
paths for your Delphi version at Update to List-Delphi-Installed-Packages.ps1 shows HKCU/HKLM keys and doesn’t truncated fields any more.
–jeroen
Via: [WayBack] Is there any way (IDE expert?) to automatic set encoding of each PAS file in UTF-8 instead of ANSI? – Jacek Laskowski – Google+
Thomas Lohrum said
For Delphi 10.2 Tokyo the correct setting is:
HKEY_CURRENT_USER\Software\Embarcadero\BDS\19.0\Editor
DefaultFileFilter=Borland.FileFilter.UTF8ToUTF8
Note, that for the value itself the term ‘Borland’ is still used!
When saving a new unit, UTF-8 will be used in conjunction with an UTF-8-BOM. This is the same as saving a file first and then let the IDE transform it to UTF-8.