如何将Delphi IDE中的默认文件格式设置为UTF8?
Delphi 2009 将新源代码文件的默认文件格式设置为 ANSI,这使得源代码与平台相关。
即使对于在 IDE 中创建的新 XSD 文件,默认情况下以此行开头,
<?xml version="1.0" encoding="UTF-8" ?>
Delphi 也会将文件格式设置为 ANSI(这看起来像是一个错误,对于新的 XML 和 XSLT 文档,默认情况下会选择 UTF8)。
是否有隐藏选项可以设置源代码文件的默认文件格式?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
事实上2004 年的这篇博文< /a> 提到了一个隐藏的 IDE 选项。
它指出您可以在注册表中设置默认文件过滤器,使 UTF-8 成为 Delphi 8 中的默认编码。这在东京仍然有效!显然,您必须将注册表项的路径调整为最新版本,如下所示:
设置此值后,Delphi 将以带有 BOM 的 UTF-8 格式对新单元进行编码。
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:
After setting this value Delphi will encode new units in UTF-8 with BOM.
在 Delphi 2009 IDE 中右键单击源代码,然后选择“文件格式”。然后选择UTF-8。希望有帮助。
Right-click on your source code in the Delphi 2009 IDE, and select File Format. Then choose UTF-8. Hope that helps.
虽然 MBulli 的答案应该仍然相关,但自从 Delphi 10.4 版本(据我记得)以来,可以更改 IDE 中的默认编码。
转到工具> 选项并选择用户界面 >导航区域中的编辑器。
您将在下面找到默认文件编码设置。
Although the answer from MBulli should be still relevant, since version 10.4 of Delphi (as far as I remember) it is possible to change the default encoding within the IDE.
Go to Tools > Options and choose User interface > Editor from the navigation area.
You will find the Default file encoding setting down below.
如果您安装 UTF8ize 插件 (他的英文翻译页面 & 最新版本)到您的IDE,当您在IDE中编辑任何文件时,插件会自动将文件的代码页设置为UTF8。
(仅供参考:作者创建了许多有用的插件。我在这里发布了他的一些带图像的插件,但我的帖子被模型师删除了。我只是想知道他有用的插件,但是,是的,这里偏离主题了。抱歉。)
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.)
AFAIK,没有 IDE 范围的设置来指定默认文件格式。
AFAIK, there is no IDE-wide setting for specifying the default file format.