I\'m upgrading some ancient (from 2003) Delphi code to Delphi Architect XE and I\'m running into a few problems. I am getting a number of errors where there are incompatibl
A couple years ago, the default character type in Delphi was changed from AnsiChar
(single-byte variable representing an ANSI character) to WideChar
(two-byte variable representing a UTF16 character.) The char
type is now an alias to WideChar
instead of AnsiChar
, the string
type is now an alias to UnicodeString
(a UTF-16 Unicode version of Delphi's traditional string type) instead of AnsiString
, and the PChar
type is now an alias to PWideChar
instead of PAnsiChar
.
The compiler can take care of a lot of the conversions itself, but there are a few issues:
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.Take a look at Delphi Unicode Migration for Mere Mortals for some more tricks and advice on how to get this to work. It's not as hard as it sounds, but it's not trivial either. Good luck!