什么是代码页 0?

发布于 2024-07-13 13:35:33 字数 163 浏览 3 评论 0原文

我正在使用 Delphi 函数,

StringCodePage

我在 COM 函数返回的字符串上调用它(Acrobat Annotation getContents - 请参阅我的其他帖子),它返回 0。0

是什么? 安西?

I'm using the Delphi function

StringCodePage

I call it on a string returned by a COM function (Acrobat Annotation getContents - see my other posts) and it returns 0.

What is 0? Ansi?

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

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

发布评论

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

评论(2

夜吻♂芭芘 2024-07-20 13:35:33

代码页 0 是 CP_ACP,当前的 Windows ANSI 代码页。

来自 Windows.pas:

{$EXTERNALSYM CP_ACP}
CP_ACP                   = 0;             { default to ANSI code page }

来自 MSDN

CP_ACP

当前系统 Windows ANSI 代码页。 该值在不同的情况下可能不同
计算机,甚至在同一网络上。 它可以在同一台计算机上更改,从而导致
存储的数据遭到不可恢复的损坏。 该值仅用于临时
如果可能的话,使用和永久存储应使用 UTF-16 或 UTF-8 来完成。

Code page 0 is CP_ACP, current Windows ANSI code page.

From Windows.pas:

{$EXTERNALSYM CP_ACP}
CP_ACP                   = 0;             { default to ANSI code page }

From MSDN:

CP_ACP

The current system Windows ANSI code page. This value can be different on different
computers, even on the same network. It can be changed on the same computer, leading to
stored data becoming irrecoverably corrupted. This value is only intended for temporary
use and permanent storage should be done using UTF-16 or UTF-8 if possible.

清君侧 2024-07-20 13:35:33

StringCodePage() 返回 0 的唯一方法是,如果您传入空白 AnsiString,从而返回其编译时代码页亲和性,或者传入非空白AnsiString 已将代码页 0 分配给其负载。 Delphi 对 COM 字符串使用 WideString,并且对于除纯 AnsiString 之外的任何字符串类型,StringCodePage() 都不会返回 0。 在 D2009 中,RTL 没有很好地将操作系统的实际运行时代码页存储到 AnsiString 有效负载中,因此它们通常包含编译时代码页关联性 0。这是功能性的到字符串转换,但不是很明确。 这个问题在更高版本的 Delphi 中得到了修复,因此 AnsiString 有效负载现在包含在运行时确定的实际操作系统代码页。

The only way StringCodePage() can return 0 is if you are passing in a blank AnsiString, thus returning its compile-time codepage affinity, or are passing in a non-blank AnsiString that has codepage 0 assigned to its payload. Delphi uses WideString for COM strings, and StringCodePage() will not return 0 for any string type except plain AnsiString. In D2009, the RTL did not do a very good job of storing the OS's actual run-time codepage into AnsiString payloads, so they commonly contained the compile-time codepage affinity of 0. That is functional in regards to string conversions, but it not very explicit. That was fixed in later Delphi versions so AnsiString payloads now contain the actual OS codepage that is determined at run-time.

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