代码编辑器无法识别俄语字符

时间:2020-03-19 12:05:19

标签: delphi non-ascii-characters delphi-10.3-rio code-editor

我正在尝试翻译project example的某些部分,其中所有注释部分和控制台输出都使用俄语,但是当通过IDE打开该项目时,似乎Code Editor无法识别该语言,例如:

enter image description here

然后,在IDE(或任何其他技巧)中是否存在可以解决该问题的设置(也适用于任何语言,不仅是俄语)?

谢谢。

1 个答案:

答案 0 :(得分:3)

Delphi代码编辑器支持非ASCII(和非ANSI)字符。只要确保对源代码使用UTF-8编码即可。

Screenshot of the Delphi source code editor with Persian text and mathematical operators.

如果在以前的非UTF文件中输入非ANSI字符并尝试保存,则IDE会询问您是否要将编码更改为UTF8:

Screenshot of dialog box asking the user if (s)he want to change the encoding to UTF8.

在任何情况下,您都可以使用编辑器的上下文菜单来设置编码:

Screenshot of the code editor's context menu, with the "File Format" submenu open. It contains various kinds of text encodings, such as ANSI and UTF8.

但是,不幸的是,当您使用非ANSI字符时,代码编辑器还是有些问题。例如,考虑以下代码行:

A line of code in the Delphi IDE's editor. It contains Persian and mathematical characters, and ends with a call to the Exit procedure. The caret is within the word "Exit".

如果此时我按Ctrl + W,我希望选择“退出”一词,因为这就是Ctrl + W的作用。但是,该行上的“奇怪”字符使编辑人员都感到困惑,这就是发生的情况:

A part of the line to the left of "Exit" has become selected.

以下是纯文本行:

ShowMessage('ریاضیات: (∂/∂t) ∫ sin(xt) dt'); Exit;