How can I set the default file format in the Delphi IDE to UTF8?

浪子不回头ぞ 提交于 2019-12-03 13:12:07

问题


Delphi 2009 sets the default file format for new source code files to ANSI, this makes the source code platform-dependent.

Even for a new XSD file created in the IDE, which by default starts with this line

<?xml version="1.0" encoding="UTF-8" ?>

Delphi sets the file format to ANSI (this looks like a bug, for new XML and XSLT documents UTF8 is selected by default).

Is there a hidden option to set the default file format for source code files?


回答1:


AFAIK, there is no IDE-wide setting for specifying the default file format.




回答2:


In fact this blog post from 2004 mentions a hidden IDE option. It states that you can set a default file filter in the registry to make UTF-8 the default encoding in Delphi 8. This still works under Tokyo! Clearly, you have to adapt the path of the registry key to recent versions like this:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Embarcadero\BDS\19.0\Editor]
"DefaultFileFilter"="Borland.FileFilter.UTF8ToUTF8"

After setting this value Delphi will encode new units in UTF-8 with BOM.




回答3:


Right-click on your source code in the Delphi 2009 IDE, and select File Format. Then choose UTF-8. Hope that helps.




回答4:


If you install UTF8ize Plugin (english translation of his page & latest version) to your IDE, when you edit any file within the IDE, the plugin set the file's codepage to UTF8 automatically.

(FYI: The author creates many useful plugins. I posted some of his plugins with image here, but my post was deleted by the modelator. I just wanted to know his useful plugins, but yes, it's off topic here. sorry.)



来源:https://stackoverflow.com/questions/1736102/how-can-i-set-the-default-file-format-in-the-delphi-ide-to-utf8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!