I am migrating a delphi 7 application to delphi XE4. In Delphi 7, some variables are declared like this:
var abc : string[80];
While migrating this code, I am changing above code declaration as
var abc : string;
As per my understanding, string[80] is ansistring and string is unicode. So, is it right way to do it?
I am following the below link from stackoverflow:
Indeed you are correct:
string[#]
are subtypes of ShortString
.string
is a regular string, which was single-byte (now called AnsiString
) up until Delphi 2007, and multi-byte (now called UnicodeString
) as of Delphi 2009.AnsiString
and UnicodeString
can have an encoding.More background information can be found in these two Delphi documentation topics:
Answering your question about how you should replace ShortString
:
It totally depends on how you used your ShortString
in Delphi 7. Depending on the use, there are multiple ways to go:
string
byte
AnsiString
That all depends on the kind of data you are storing, so that is the first thing you need to find out.