Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-08

strcopy, strlcopy for PWideChar

11 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

LacaK

Hi,
it seems, that there is ATM no versions of StrCopy, StrLCopy, which works with WideChars (in SysUtils).
Can these variants be added ?

function StrCopy(Dest: PWideChar; const Source: PWideChar): PWideChar;
http://docwiki.embarcadero.com/VCL/en/SysUtils.StrCopy
function StrLCopy(Dest: PWideChar; const Source: PWideChar; MaxLen: Cardinal): PWideChar;
http://docwiki.embarcadero.com/VCL/en/SysUtils.StrLCopy

etc.

Or do you not like these "wide" versions at all ?

TIA
-Laco.

Reply by email

Michael Van Canneyt
to LacaK
LacaK wrote 15 lines
Hi, it seems, that there is ATM no versions of StrCopy, StrLCopy, which works with WideChars (in SysUtils). Can these variants be added ? function StrCopy(Dest: PWideChar; const Source: PWideChar): PWideChar; http://docwiki.embarcadero.com/VCL/en/SysUtils.StrCopy function StrLCopy(Dest: PWideChar; const Source: PWideChar; MaxLen: Cardinal): PWideChar; http://docwiki.embarcadero.com/VCL/en/SysUtils.StrLCopy etc. Or do you not like these "wide" versions at all ?

It's not a matter of liking, I'm afraid.
If Delphi has them, we'll have to add them too :-)

Can you please add an entry in the bug tracker, so we don't forget ?

Michael.

Reply by email

LacaK
to Michael Van Canneyt

Michael Van Canneyt wrote / napísal(a):

Show quoted text 25 lines
On Mon, 15 Aug 2011, LacaK wrote: > Hi, > it seems, that there is ATM no versions of StrCopy, StrLCopy, which > works with WideChars (in SysUtils). > Can these variants be added ? > > function StrCopy(Dest: PWideChar; const Source: PWideChar): PWideChar; > http://docwiki.embarcadero.com/VCL/en/SysUtils.StrCopy > > function StrLCopy(Dest: PWideChar; const Source: PWideChar; MaxLen: > Cardinal): PWideChar; > http://docwiki.embarcadero.com/VCL/en/SysUtils.StrLCopy > > etc. > > Or do you not like these "wide" versions at all ? It's not a matter of liking, I'm afraid. If Delphi has them, we'll have to add them too :-) Can you please add an entry in the bug tracker, so we don't forget ?

http://bugs.freepascal.org/view.php?id=19989
Do you think, that it is realistic expect them in 1-2 months ? Thanks
-Laco.

Reply by email

Michael Van Canneyt
to LacaK
LacaK wrote 28 lines
Michael Van Canneyt wrote / napísal(a): > > > On Mon, 15 Aug 2011, LacaK wrote: > >> Hi, >> it seems, that there is ATM no versions of StrCopy, StrLCopy, which works >> with WideChars (in SysUtils). >> Can these variants be added ? >> >> function StrCopy(Dest: PWideChar; const Source: PWideChar): PWideChar; >> http://docwiki.embarcadero.com/VCL/en/SysUtils.StrCopy >> >> function StrLCopy(Dest: PWideChar; const Source: PWideChar; MaxLen: >> Cardinal): PWideChar; >> http://docwiki.embarcadero.com/VCL/en/SysUtils.StrLCopy >> >> etc. >> >> Or do you not like these "wide" versions at all ? > > It's not a matter of liking, I'm afraid. If Delphi has them, we'll have to > add them too :-) > > Can you please add an entry in the bug tracker, so we don't forget ? > http://bugs.freepascal.org/view.php?id=19989 Do you think, that it is realistic expect them in 1-2 months ?

Not unless someone donates a patch.

Michael.

Reply by email

Hans-Peter Diettrich
to LacaK: Michael Van Canneyt wrote / napísal(a): http://bugs.freepascal.org/view.php?id=19989 Do…
Show quoted text 9 lines
>> Or do you not like these "wide" versions at all ? > > It's not a matter of liking, I'm afraid. If Delphi has them, we'll > have to add them too :-) > > Can you please add an entry in the bug tracker, so we don't forget ? > http://bugs.freepascal.org/view.php?id=19989 Do you think, that it is realistic expect them in 1-2 months ?

Supply an patch, to speed up the implementation.

But first the Delphi implementations should be explored, since the following looks not okay to me:

"StrLCopy copies a maximum MaxLen characters from Source to Dest, then adds a null terminator to Dest and returns Dest. The SizeOf standard function (Delphi) or the sizeof operator (C++) can be used to determine the MaxLen parameter. Usually, MaxLen equals SizeOf(Dest)-1."

The mix (or equivalence) of character and byte counts obviously is inappropriate for "wide" versions. Perhaps "sizeof" should read "Length"?

DoDi

Reply by email

LacaK
to Hans-Peter Diettrich

Hans-Peter Diettrich wrote / napísal(a):

Show quoted text 13 lines
LacaK schrieb: >>> Or do you not like these "wide" versions at all ? >> >> It's not a matter of liking, I'm afraid. If Delphi has them, we'll >> have to add them too :-) >> >> Can you please add an entry in the bug tracker, so we don't forget ? >> > http://bugs.freepascal.org/view.php?id=19989 > Do you think, that it is realistic expect them in 1-2 months ? Supply an patch, to speed up the implementation.

Ok, I can try prepare patch, but only "generic" i.e. which uses only Pascal. Processor specific implementations (which use assembler, like it is done for AnsiString versions) I am afraid is too dificult for me ATM ;-) And also decision where to put (in which units) these functions I will leave to somebody more familiar with unit dependencies.

Show quoted text 12 lines
But first the Delphi implementations should be explored, since the following looks not okay to me: "StrLCopy copies a maximum MaxLen characters from Source to Dest, then adds a null terminator to Dest and returns Dest. The SizeOf standard function (Delphi) or the sizeof operator (C++) can be used to determine the MaxLen parameter. Usually, MaxLen equals SizeOf(Dest)-1." The mix (or equivalence) of character and byte counts obviously is inappropriate for "wide" versions. Perhaps "sizeof" should read "Length"?

Yes, I will do it. I expect, that length is in this case "character length", so "byte length" is "character length"*sizeof(widechar)

-Laco.

Show quoted text 6 lines
DoDi _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Marco van de Voort
to Felipe Monteiro de Carvalho

In our previous episode, Felipe Monteiro de Carvalho said:

Show quoted text 5 lines
wrote: > The mix (or equivalence) of character and byte counts obviously is > inappropriate for "wide" versions. Perhaps "sizeof" should read "Length"? Maybe Delphi supports only UCS-2 and not UTF-16

Delphi afaik supports UTF-16 as a stringtype (afaik all routines route to system routines that keep track of surrogates), but only provides 2-byte array level access for []

Reply by email

Florian Klämpfl
to LacaK: Hans-Peter Diettrich wrote / napísal(a): Ok, I can try prepare patch, but only…
LacaK wrote 16 lines
Hans-Peter Diettrich wrote / napísal(a): > LacaK schrieb: > >>>> Or do you not like these "wide" versions at all ? >>> >>> It's not a matter of liking, I'm afraid. If Delphi has them, we'll >>> have to add them too :-) >>> >>> Can you please add an entry in the bug tracker, so we don't forget ? >>> >> http://bugs.freepascal.org/view.php?id=19989 >> Do you think, that it is realistic expect them in 1-2 months ? > > Supply an patch, to speed up the implementation. Ok, I can try prepare patch, but only "generic" i.e. which uses only Pascal.

It's the prefered way anyways. First, make a good pascal version, if someone needs it, he can look into creating an assembler one for some cpus.

Reply by email

Hans-Peter Diettrich
to Felipe Monteiro de Carvalho: On Mon, Aug 15, 2011 at 6:41 PM, Hans-Peter Diettrich Maybe Delphi supports only UCS-2…
Show quoted text 6 lines
On Mon, Aug 15, 2011 at 6:41 PM, Hans-Peter Diettrich wrote: > The mix (or equivalence) of character and byte counts obviously is > inappropriate for "wide" versions. Perhaps "sizeof" should read "Length"? Maybe Delphi supports only UCS-2 and not UTF-16

String encodings should not play a role, when e.g. memory has to be allocated or copied (see SetLength). The MaxLen parameter indicates the number of physical units (bytes or words).

DoDi

Reply by email

LacaK
to Florian Klämpfl: It's the prefered way anyways. First, make a good pascal version, if someone needs it, he…

Florian Klämpfl wrote / napísal(a):

Show quoted text 27 lines
Am 16.08.2011 07:06, schrieb LacaK: > Hans-Peter Diettrich wrote / napísal(a): > >> LacaK schrieb: >> >> >>>>> Or do you not like these "wide" versions at all ? >>>>> >>>> It's not a matter of liking, I'm afraid. If Delphi has them, we'll >>>> have to add them too :-) >>>> >>>> Can you please add an entry in the bug tracker, so we don't forget ? >>>> >>>> >>> http://bugs.freepascal.org/view.php?id=19989 >>> Do you think, that it is realistic expect them in 1-2 months ? >>> >> Supply an patch, to speed up the implementation. >> > Ok, I can try prepare patch, but only "generic" i.e. which uses only > Pascal. > It's the prefered way anyways. First, make a good pascal version, if someone needs it, he can look into creating an assembler one for some cpus.

I posted generic pascal versions in bug report
http://bugs.freepascal.org/view.php?id=19989#bugnotes Please review (and commit if all ok).
Thanks
-Laco.

Reply by email