将带有特殊字符的 Delphi DFM 迁移到 D2009

发布于 2024-07-18 09:11:31 字数 611 浏览 5 评论 0原文

我有许多 Delphi 表单,其中我们使用几个特殊字符 - “度”符号和“欧姆”符号。 这些字符用于保存在 DFM 文件中的标签标题,并且不会在运行时生成或修改。 回到我们第一次设计这些形式时,度数符号很容易,因为它位于 Ansi 字符集(代码 176)中,但欧姆符号需要希腊字符集才能与代码 217 一起使用。幸运的是(我们发现)我们可以使用的所有其他字符需要(字母和数字)与希腊字符集配合良好。

现在我们希望这些表单在 D2009 中看起来相同。 度数符号看起来很好,但欧姆符号显示“Ù”,因为 dfm 文本为“Caption = 'Typed in Ohms - 1234 '#217”。 我发现我可以编辑表单以输入正确的 unicode 欧姆符号 (8486),但当然这会丢失为“?” 返回D7时。 理想情况下,我想告诉 D2009 继续使用带有形式的希腊字符集,以便 dfm 中的 #217 映射到欧姆符号。 这可能吗? 它似乎忽略了“GREEK_CHARSET”的 Font.Charset 设置。 我发现了一种解决此问题的肮脏方法,即迭代所有组件并执行“S​​tringReplace( S, 'Ù', OhmsChar, [rfReplaceAll] )”,但这太可怕了,肯定有更好的方法吗?

谢谢, 布莱恩

I've got a number of Delphi forms where we use a couple of special characters - the 'degree' symbol, and the 'ohms' symbol. These characters are used in label captions saved in the DFM file and are not generated or modified at runtime. Back along when we first designed these forms the degree symbol was easy because it is in the Ansi character set (code 176) but the ohms symbol needed the greek charset to be used with code 217. Fortunately (we found) all other characters that we need (letters and numbers) work fine with the greek charset.

Now we would like these forms to look the same in D2009. The degree symbol appears fine but the ohms symbol shows 'Ù' because the dfm text is "Caption = 'Typed in Ohms - 1234 '#217". I find that I can edit the form to put in the correct unicode ohms symbol (8486) but of course this is lost to a '?' when going back to D7. Ideally I'd like to tell D2009 to continue to use the greek charset with the form so that #217 in the dfm maps to the ohms symbol. Is this possible? It seems to ignore the Font.Charset setting which is 'GREEK_CHARSET'. I have discovered a dirty way of solving this which is to iterate through all the components and doing "StringReplace( S, 'Ù', OhmsChar, [rfReplaceAll] )", but this is horrible and surely there must be a better way?

Thanks,
Brian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

关于从前 2024-07-25 09:11:32

正如 Bruce 已经提到的,您可以使用代码来给出这些值。 我只是举一个例子和一些额外的信息。

resourcestring
{$IFDEF UNICODE}
  cOhm = unicodeohm;        // replace with correct values.
  cDegree = unicodedegree;
{$ELSE}
  cOhm = ansiohm;
  cDegree = ansidegree;

我建议对可翻译文本使用资源字符串而不是 const,因为大多数翻译工具都适用于资源。

As Bruce already mentioned, you can use the code to give these values. I just give an example and some extra information.

resourcestring
{$IFDEF UNICODE}
  cOhm = unicodeohm;        // replace with correct values.
  cDegree = unicodedegree;
{$ELSE}
  cOhm = ansiohm;
  cDegree = ansidegree;

I advise to use resource strings and not const for translatable text, because most translation tools work on resources.

我偏爱纯白色 2024-07-25 09:11:32

我发现执行此操作的最简洁方法是在代码中填充这些“特殊”标题,如有必要,您可以在其中使用 IFDEF。

The cleanest way I found to do this was to populate these "special" captions in code, where you can use IFDEFs if necessary.

滥情空心 2024-07-25 09:11:31

我遇到的类似问题是通过使用 dxgettext 解决的。 我没有使用有问题的字幕,而是使用干净的 ascii(例如“输入欧姆”),然后将它们翻译成 po 文件,作为资源嵌入到 exe 中。

顺便说一句, dxgettext 是一种向应用程序添加翻译的好方法,只需很少的开销和标准格式(po /mo) 和优秀的 3p 编辑器 (poEdit)。 适用于 D7 和 D2009。

Similar issue I had was solved by using dxgettext. Instead of problematic captions, I just used clean ascii (eg. "Typed in Ohms"), and then translated them in po files, embedded in exe as resources.

BTW, dxgettext is a nice way to add translations to app, with a very little overhead and standard formats (po/mo) with good 3p editors (poEdit). Works with D7 and D2009.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文