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

Mailing lists / fpc-pascal / 2012-03
12 messages · 8 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
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
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 (' !'));-Flávio
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.
Brought up in Lazarus forums. Fpc Trim(): Trim whitespace from the ends of a string.…
Depends on what you mean by whitespace, of course. FPC strips everything below Ord(' '), and thus should behave the same as Delphi.
Michael.
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()
Depends on what you mean by whitespace, of course. FPC strips everything below Ord(' '),…
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
The documentation is incorrect. It says: "Description Trim strips blank characters…
Bernd wroteThe documentation is incorrect. It says:
Yes, and I misread the actual implementation.
I was too lazy to write a test program.
I really shouldn't post "bugs" after 23:00 (local time).
Sorry for wasting your time.
Bart
The documentation is incorrect. It says: "Description Trim strips blank characters…
Bernd wroteThe 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.
No need. I already fixed the docs.
You're writing (code/docs) faster than I can think ;-)
Bart
Bart wroteYou'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! :-)