On Sat, Dec 21, 2013 at 1:18 PM, Juha Manninen <[email protected]> wrote: > On Sat, Dec 21, 2013 at 4:33 PM, Marcos Douglas <[email protected]> wrote: >> That's it! >> I think you talking about of new versions of Delphi, right? So I >> always read that "new Unicode implementation" in new versions of >> Delphi is wrong, broke things, etc. but you is writing other vision. > > Yes, Delphi 2009+. Delphi 2009 is soon 5 years old, not really new any more. > IMO it does a good job for such a fundamental change in string type. > Only code that relies on "sizeof(char) = 1" does not work. It includes > streaming strings, file I/O or I/O with some outside devices, using > Length(Str) as a parameter for GetMem(), Move() etc. > Most "clean" code works amazingly well, if you are ok with using > UTF-16 everywhere. > > >> These conversions, IMHO, could be automatic -- as Delphi does -- when >> I use the correct type of string, in that case UT8String. So, I can >> write my packages and opt to use only UTF8String or UTF16String in all >> arguments and the compiler convert for me. What is wrong in that >> approach? > > Nothing wrong I guess. I hope it will be possible with FPC. Still, > let's not speculate more, we already have such mail threads in fpc-dev > list that continued for months. > > >> If you do not want automatic conversions, use the RawByteString type. >> Delphi does not do conversions in that case, right? >> Thank you, I'm learning. > > You can bypass the conversion sometimes by using RawByteString but it > would be rather hackish. Remember, all VCL classes and string > functions expect UTF-16. I don't want to try what happens if you pass > them a UTF-8 encoded string using some hack. > The bottom line is: Use only UTF-16 with Delphi and it works very well.
I always said here -- FPC/Lazarus lists -- that FPC should never follow Delphi but you're making me change my mind about Unicode implementation. Ok, no more speculations about how next FPC will work with Unicode. >> For example, I use a lot PostMessage, SendMessage, PeekMessage... Are >> these cross-plataform? If not, how can I do the same? > > LCL (and VCL) typically use events, like TNotifyEvent. They are > basically just call-back functions. Oh, not same. I use a lot Events -- no only Form or GUI components -- in my core codes but PostMessage is very different, eg., you call a PostMessage, show a Modal Form and the process will start after; the task code is not inside the instance of the Form and the Form knows nothing about the task. Marcos Douglas -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
