What would be the best process to convert a very old ANSI charset based Win32 application to UNICODE? The source code is currently compiled with Delphi7. Would it be best to make this conversion with which Delphi version? I have currently a license for XE6 version, is it worth of using that one?
There are plenty of .pas and .dfm files so AI would be the preferred method.
The code is using both STRING (oldest) and ANSISTRING, pchar, TStringList, TStreamFile. The code is compatible with all Windows versions from Windows95 to Win11.
This is just a tiny example how strings are used:
function LocalizeGUI.LanguageCodeStr( code :string ): integer;
var
rowlist : tstringlist;
st,j,i : integer;
alang: ansistring;
begin
st := 0;
if code = '' then code := Setting_ActiveLANGUAGE;
for i := 0 to languages.count - 1 do begin
alang := '';
RowList:= StrParse(Languages.strings[i],'=');
if (rowlist<>nil )and (rowlist.count>0) then
if uppercase(rowlist.strings[1]) = uppercase(code) then st := i;
RowList.free;
end;
result := st;
end;
best
? What happens when you try it with any version you have available?st
whenresult
would do already? Why not exiting the loop upon a match?) and inconsistent (indention, spaces, unused variables) this code alone is written I suggest you manually go through all that, as you potentially find lots of quirks and bugs anyway. Or ruin it with AI right away.String
,PChar
, etc then most code will migrate to Unicode with little to no change. If you are usingAnsiString
/PAnsiChar
explicitly, they will continue to work as-is, though you may get compiler warnings/errors about data conversions, etc. The best option in your use case is to make use ofTEncoding
to convert ANSI data to Unicode as soon as it enters your app, and vice versa when leaving your app. Things likeTStringList
,TFile
, etc haveTEncoding
overloads available. Process strings only in Unicode (asUnicodeString
orUTF8String
)