我正在将一些古老的(2003年)Delphi代码升级到DelphiArchitectXE,我遇到了一些问题。我在存在不兼容类型的地方遇到了许多错误。这些错误不会在Delphi6中发生,所以我必须假设这是因为事情已经升级了。
老实说,我不知道PAnsiChar和PWideChar之间的区别是什么,但Delphi肯定知道区别,不会让我编译。如果我知道差异是什么,也许我可以弄清楚该使用哪一个或如何解决这个问题。
我正在将一些古老的(2003年)Delphi代码升级到DelphiArchitectXE,我遇到了一些问题。我在存在不兼容类型的地方遇到了许多错误。这些错误不会在Delphi6中发生,所以我必须假设这是因为事情已经升级了。
老实说,我不知道PAnsiChar和PWideChar之间的区别是什么,但Delphi肯定知道区别,不会让我编译。如果我知道差异是什么,也许我可以弄清楚该使用哪一个或如何解决这个问题。
缩写:在Delphi 2009之前,Delphi中的原生字符串类型曾经是ANSI CHAR:每个字符串中的每个字符都表示为8位字符。从Delphi 2009开始,Delphi的字符串变成了UNICODE,使用UTF-16表示法:现在基本的Char使用16位数据(2个字节),您可能不需要了解太多关于表示为两个连续16位字符的UNICODE代码点的信息。
The 8 bit chars are called "Ansi Chars". An PAnsiChar is a pointer to 8 bit chars. The 16 bit chars are called "Wide Chars". An PWideChar is a pointer to 16 bit chars. Delphi knows the difference and does well if it doesn t allow you to mix the two!
更多信息
以下是Unicode上的一个流行链接:每个软件开发人员绝对、积极地必须知道的关于Unicode和字符集的绝对最小值
您可以在此处找到有关将Delphi迁移到Unicode的更多信息:新白皮书:用于Mere Mortals的Delphi Unicode迁移
您也可以在SO中搜索“Delphi Unicode迁移”。
几年前,Delphi中的默认字符类型从 编译器本身可以处理很多转换,但也存在一些问题: 看看Delphi Unicode Migration for Mere Mortals了解更多关于如何实现这一点的技巧和建议。这并不像听起来那么难,但也不是小事。祝你好运!AnsiChar
(表示ANSI字符的单字节变量)更改为WideChar
char类型现在是WideChar
的别名,而不是AnsiChar,
string
类型现在是UnicodeString
(Delphi传统字符串类型的UTF-16 Unicode版本)的别名,而不是AnsiString
,PChar
现在是PWideChar
的别名,不是PAnsiChar
PChar
, you need to make sure your pointer is pointing to the right type of data, and the compiler can t always verify this.string
as a convenient byte-array buffer for holding arbitrary data instead of a variable that holds text, that won t work as a UnicodeString
. Make sure those are declared as RawByteString
as a workaround.char
is one byte long.
my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...
Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...
i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...
In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...
What is the equivalent of SetLength using Oxygene? I m trying to size an integer array. var listIndexes: array of integer; begin setLength(listIndexes,5); // doesn t work end;
How can I monitor or visualize memory fragmentation of a delphi application?
I have consistently had IDE problems in Delphi/C++Builder for years, with every version. I usually just reboot, recompile, etc. and move on. However, I keep seeing others say that the IDE is rock ...
I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...