[fpc-pascal] The new Delphi compatible unicode string

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Tue Jan 4 14:08:01 CET 2011



On Tue, 4 Jan 2011, Juha Manninen wrote:

> michael.vancanneyt at wisa.be kirjoitti tiistai 04 tammikuu 2011 12:42:44:
>> On Tue, 4 Jan 2011, Juha Manninen wrote:
>>> This component would really benefit from the Delphi2009 default string
>>> type. All string encoding problems would be solved automatically.
>>
>> That is simply not correct.
>>
>> I am in the process of converting a D7 application to a D2010 application.
>> There are lots of string encoding problems, and none of them is solved
>> "automatically".
>
> What kind of problems did you have?
>
> I used Delphi 2009 for a while at my former workplace. At least it worked with
> my existing Delphi programs amazingly well. The compiler sometimes warned
> about automatic conversion between string types but still it worked.

Not so here. Off the top of my mind:
- Explicit encodings run awry
- Some Components that used explicit Windows DoSomeThingA calls no longer functioned.
   (TProcess for instance suffers)
- Database fields change type.
- Strings were saved to stream. All instances where that happened, String
   had to be changed to AnsiString explicitly

Further, many standard Delphi components had changed their interface.
IBExpress, Midas etc. jump to mind. They may not have anything to do 
with the strings issue, but they add to the confusion.

In short: Migrating a 1.2 million line app from D7 to Delphi 2010 is not a
trivial task at all, and a substantial part is due to the strings issue.

>
> The string uses UTF-16 encoding and converts automatically from other string
> types. It pretty much solves the unicode encoding problems automatically, IMO.
> If there is again some detail of unicode that I don't understand, I am willing
> to learn more.
>
> My guess is the problems come with old pascal code with shortstrings and
> pointers. (?)
>
>
>> Furthermore, if you need to support both the old and new string type
>> (i.e. keep it compilable with older Delphi/FPC versions) you'll always
>> need IFDEFS in your code.
>
> No, my whole idea is to modernize the code and NOT support old versions.
> There are already 2 maintained versions that support old compilers and old
> string types.
> I am often questioning myself if it makes sense to use this historical
> language.

Do not understand me wrong, I am all for the new string type.

But I simply do not think it is as painless as you seem to think it is.
Secondly, not everyone wants to jump to the latest and greatest version, so
I thought you might want to keep the old version. If you don't, fine.

And for the record: Java is almost as old as Object Pascal. 
I remember well the first attempts to run Java on a Alpha DecStation 
back in the whereabouts of 1994.

Michael.



More information about the fpc-pascal mailing list