Saturday, January 23, 2021

Porting an application to Windows 10/Delphi 10.2 (part 4)

Continuing ...

The main form with its grid now displays correctly, but I discovered that another unit that displays data initially in a twebbrowser and thence into Word does not work correctly.

The data is extracted from the database and stored in a tstringlist containing raw HTML tags; this stringlist is saved as a file then read into the web browser. The HTML itself is defined as Utf-8 as a result of my standard header code that includes the command "charset=UTF-8". The web browser would display a impressing number of diamonds, a clear sign that there were translation problems. Ironically, right clicking on the browser, choosing the 'Encoding' option and changing this to 'Hebrew (Windows)' would cause the Hebrew text to display correctly, but the data that contained Russian (the whole point of porting the application) would be displayed as question marks. Obviously this is wrong.

After about another hour of banging my head against a wall, the solution finally came to me - and it's something that I had already used, albeit not in this program: the stringlist is saved to a file; add the second parameter to the 'saveasfile' procedure.

savetofile (fn, TEncoding.UTF8);

Now everything works correctly on my development computer. Will it work on the target computer? Not quite: after moving five steps forward, I'm back to a basic problem, that the program can't find its database.

[Edit: I don't know what the actual problem was. I recompiled the program on the target computer and it started working properly, both inside and outside of Delphi. I'm going to keep the Delphi installation on the target computer; it will help solve future problems.]

No comments: