delphidelphi-7

Converting my old AnsiString based D7 app to Unicode with AI?


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;

Solution

  • Embarcadero provides a very comprehensive site containing lots of information about how to migrate Delphi or C++Builder apps in different ways (e.g. Unicode, x64, databases, etc.):

    Migration and Upgrade Center

    In the section for Unicode migration you can find the Unicode Statistics Tool (for downloading it a free CDN account is required):

    This Unicode Statistics Tool will assist you in collecting useful statistics for the time and effort needed to migrate your Delphi applications to Unicode.

    The tool reviews your code and tells you where and what you will most likely have to change. This will at least give you an estimate of how many lines need to be reviewed.

    So together with the other resources available you should have a good grasp of what you really have to do or change for a successful migration, whether manually or AI-driven.

    Regarding you question about which Delphi version to use for the Unicode migration process:
    It doesn't really matter at all, each Unicode enabled Delphi version is sufficient (that is, Delphi 2009 to 2010, XE to XE8, and 10.0 to 12.1, at the time of this writing). What matters more in this case is, what 3rd party components used in the original project are available for which later Delphi versions. But that's a different topic...