拉撒路。相当于 Unicode 符号的 Chr()
freepascal中有没有函数可以通过代码显示Unicode符号(例如U+1D15E)?不幸的是 Chr()
仅适用于 ANSI 符号(代码小于 127)。
我想使用自定义符号字体中的符号,但将它们直接放入源代码中非常不方便(它们在 Lazarus 中显示为 ?
或其他内容,因为它们在系统字体中不存在)。
Is there any function in freepascal to show the Unicode symbol by its code (e.g. U+1D15E)? Unfortunately Chr()
works only with ANSI symbols (with codes less than 127).
I want to use symbols from custom symbolic font and it is very inconvenient to put them into sourcecode directly (they are shown in Lazarus as ?
or something else because they are absent in system fonts).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看此页面。我假设 Freepascal 要么使用 UTF-16,其中它成为两个 WideChar 的代理对(见表),要么使用 UTF-8,其中它成为字节值序列(再次见表)。
UTF-8:
UTF-16:
字符串类型的名称可能不同,因为我不太了解 FreePascal。也许 AnsiString 和 WideString。
Take a look at this page. I assume that Freepascal either uses UTF-16, in which it becomes a surrogate pair of two WideChars (see table) or UTF-8, in which it becomes a sequence of byte values (see table again).
UTF-8:
UTF-16:
The names of the string types may differ, as I don't know FreePascal very well. Perhaps AnsiString and WideString.
我从未使用过 Free Pascal,但如果我是你,我会尝试
,或者,如果编译器真的很顽固,
I have never used Free Pascal, but if I were you, I'd try
or, if the compiler is really stubborn,
据我所知,FPC 当前的 unicode 状态
更新:2.7.1 有一个可变编码 ansisstring 类型,并且 lazarus 已修复以继续工作。不过,还没有真正利用它,例如,大多数 RTL 仍然使用 -A 调用,并且采用字符串的 sysutils 和系统过程的原型尚未更改为 rawbytestring。
Current unicode status of FPC to my best knowledge
Update: 2.7.1 has a variable encoding ansistring type, and lazarus has been fixed to keep working. Nothing is really taking advantage from it yet though, e.g. most of the RTL still uses -A calls, and prototypes of sysutils and system procedures that takes strings haven't changed to rawbytestring yet.
我假设问题是从 UCS4 编码(实际上是 Unicode 代码点编号)转换为 UTF16。
在Delphi中,您可以使用
UCS4StringToUnicodeString
函数。警告:要小心
UCS4String
类型。它实际上是一个以零结尾的动态数组,而不是一个字符串(这意味着它是从零开始的)。I assume the problem is to convert from UCS4 encoding (which is actually a Unicode codepoint number) to UTF16.
In Delphi, you can use
UCS4StringToUnicodeString
function.Warning: Be careful with
UCS4String
type. It is actually a zero-terminated dynamic array, not a string (that means it is zero-based).