#1 2015-11-01 08:57:08

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Safe to use implicit RawUTF8 <-> string conversion in unicode Delphi?

Hi,

It seems to be working well, but I'm still not 100% sure about it - is it safe to use implicit RawUTF8 <-> string conversion in unicode Delphi (version after 2009)?

I mean:
- directly pass values of type 'String/UnicodeString' to mORMot functions that expect type 'RawUTF8', eg:

var
  mystr: string;
begin
  myDb.ExecuteList([], myStr);
end;

- Directly assigning RawUTF8 to String, eg:

var
  myUtf8: RawUTF8;
begin
  TEdit.Text := myUtf8;
end;

Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2015-11-01 16:48:04

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Safe to use implicit RawUTF8 <-> string conversion in unicode Delphi?

It work, but VERY slow, so better convert values manually using functions from SynCommons

Online

#3 2015-11-02 06:30:49

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Safe to use implicit RawUTF8 <-> string conversion in unicode Delphi?

@mpv, thanks for your comments. I'm curious, the implicit conversion is slow when compared to using functions in SynCommons, because of the internal RTL functions used to perform the implicit conversion is not optimized, right?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2015-11-02 07:21:01

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Safe to use implicit RawUTF8 <-> string conversion in unicode Delphi?

It's better explained in @ABs perfect blog article How to write fast multi-thread Delphi applications..

Online

Board footer

Powered by FluxBB