Sign in Join

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

Mailing lists / fpc-pascal / 2012-03

Trim(): incompatibility with Delphi

12 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

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

Bart

Hi,

Brought up in Lazarus forums.

Fpc Trim(): Trim whitespace from the ends of a string. Delphi Trim(): Trims leading and trailing spaces and control characters from a string.

Bug or by design?

Bart

Reply by email

Mark Morgan Lloyd
to Flávio Etrusco
Flávio Etrusco wrote 10 lines
On Mon, Mar 5, 2012 at 11:36 PM, leledumbo wrote: >> Fpc Trim(): Trim whitespace from the ends of a string. > Where did you get that? The documentation > (http://www.freepascal.org/docs-html/rtl/sysutils/trim.html) doesn't say > so... > And a simple test confirms the docs (FPC 2.6): ShowMessage(Trim('test ') + Trim (' !'));

More to the point, putting in control characters instead of spaces:

program trimtest;
uses SysUtils;
begin
   WriteLn(Trim('test' + #$0d + #$0a) + Trim (#$0d + #$0a + '!'))
end.

test!

Unless there's some weird locale-specific problem.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Bernd
to Unknown author

The documentation is incorrect. It says:

"Description

Trim strips blank characters (spaces) at the beginning and end of S and returns the resulting string. Only #32 characters are stripped. "

But it will strip everything <= #32, not only #32 as the documentation suggests. The same error is in the docs for TrimLeft() and TrimRight()

Reply by email

patspiper
to Unknown author: Depends on what you mean by whitespace, of course. FPC strips everything below Ord(' '),…
Show quoted text 14 lines
On Mon, 5 Mar 2012, Bart wrote: > Hi, > > Brought up in Lazarus forums. > > Fpc Trim(): Trim whitespace from the ends of a string. > Delphi Trim(): Trims leading and trailing spaces and control > characters from a string. Depends on what you mean by whitespace, of course. FPC strips everything below Ord(' '), and thus should behave the same as Delphi.

From http://www.freepascal.org/docs-html/rtl/sysutils/trim.html:

"Trim strips blank characters (spaces) at the beginning and end of S and returns the resulting string. Only #32 characters are stripped."

Stephano

Reply by email

Graeme Geldenhuys
to Bernd: The documentation is incorrect. It says: "Description Trim strips blank characters…
Bernd wrote
The documentation is incorrect. It says:

As usual, please file a 'FPC >> Docs' bug report so the issue doesn't get forgotten. It should be auto-assigned to Michael van Canneyt. Supplying a documentation patch is always nice too.

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Unknown author
to Graeme Geldenhuys
Graeme Geldenhuys wrote 7 lines
On 6 March 2012 18:12, Bernd wrote: > The documentation is incorrect. It says: As usual, please file a 'FPC >> Docs' bug report so the issue doesn't get forgotten. It should be auto-assigned to Michael van Canneyt. Supplying a documentation patch is always nice too.

No need. I already fixed the docs.

Michael.

Reply by email

Graeme Geldenhuys
to Bart
Bart wrote
You're writing (code/docs) faster than I can think ;-)

Yeah, I'm jealous about that too. Maybe he perfected his clones - mine went totally haywire after a while! :-)

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email