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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With