Sign in Join

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

Mailing lists / fpc-pascal / 2011-11

Is there a bug in TStrings.Delimiter handling?

12 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

Frank Church

adapterVals: TStringList

adapterVals.Delimiter := ';';
adapterVals.DelimitedText := '192.168.1.2,00:0E:08:E0:7C:ED,Word Space'; adapterVals[0] = '192.168.1.2'
adapterVals[1] = '00:0E:08:E0:7C:ED'
adapterVals[2] = 'Word' - this should be 'Word Space'

Is this a bug or the expected output? If the delimiter is set to a comma it shouldn't treat a space as a delimter as well.

Frank Church ======================= http://devblog.brahmancreations.com
Graeme Geldenhuys
to Frank Church
Frank Church wrote
adapterVals: TStringList adapterVals.Delimiter := ';'; adapterVals.DelimitedText := '192.168.1.2,00:0E:08:E0:7C:ED,Word Space';

I take it this is a typo, and you ment to have the comma's as semi-colons.

adapterVals[2] = 'Word' - this should be 'Word Space' Is this a bug or the expected output? If the delimiter is set to a comma it shouldn't treat a space as a delimter as well.

Sadly, this is the exact same output as given by Delphi 7. But that still doesn't make it right (Delphi is not immune to bugs), and I don't think FPC should start cloning Delphi bugs too. I read the Delphi 7 help, and there is no mention of special handling when a Space character is involved in the DelimitedText value. So this sure looks like a bug to me.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/
Marco van de Voort
to Frank Church: adapterVals: TStringList adapterVals.Delimiter := ';'; adapterVals.DelimitedText :=…

In our previous episode, Frank Church said:

Show quoted text 10 lines
adapterVals: TStringList adapterVals.Delimiter := ';'; adapterVals.DelimitedText := '192.168.1.2,00:0E:08:E0:7C:ED,Word Space'; adapterVals[0] = '192.168.1.2' adapterVals[1] = '00:0E:08:E0:7C:ED' adapterVals[2] = 'Word' - this should be 'Word Space' Is this a bug or the expected output? If the delimiter is set to a comma it shouldn't treat a space as a delimter as well.

This is the expected output and delphi compatible.

Hint: set adapterVals.strictdelimiter:=true
Graeme Geldenhuys
to Unknown author: A space is always treated special. You should either enclose values with spaces in…
A space is always treated special.

Where in the Delphi documentation does it mention that? I couldn't find any such reference in the Delphi 7 docs, and I thought FPC implements behaviour based on documented behaviour, not implementation behaviour?

And does FPC implement Delphi bugs too? If so, that is sad.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/
Unknown author
to Frank Church: adapterVals: TStringList adapterVals.Delimiter := ';'; adapterVals.DelimitedText :=…
Frank Church wrote 10 lines
adapterVals: TStringList adapterVals.Delimiter := ';'; adapterVals.DelimitedText := '192.168.1.2,00:0E:08:E0:7C:ED,Word Space'; adapterVals[0] = '192.168.1.2' adapterVals[1] = '00:0E:08:E0:7C:ED' adapterVals[2] = 'Word' - this should be 'Word Space' Is this a bug or the expected output? If the delimiter is set to a comma it shouldn't treat a space as a delimter as well.

A space is always treated special.

You should either enclose values with spaces in quotes, or set the StrinctDelimiter property to true, in which case the space loses its special meaning.

I recommend the second.

Michael.

Unknown author
to Unknown author
Show quoted text 20 lines
On Mon, 21 Nov 2011, Frank Church wrote: > adapterVals: TStringList > > adapterVals.Delimiter := ';'; > adapterVals.DelimitedText := '192.168.1.2,00:0E:08:E0:7C:ED,Word Space'; > adapterVals[0] = '192.168.1.2' > adapterVals[1] = '00:0E:08:E0:7C:ED' > adapterVals[2] = 'Word' - this should be 'Word Space' > > Is this a bug or the expected output? If the delimiter is set to a comma it > shouldn't treat a space as a delimter as well. A space is always treated special. You should either enclose values with spaces in quotes, or set the StrinctDelimiter property to true, in which case the space loses its special meaning.

Typo, should be StrictDelimiter, of course.

Michael.

Graeme Geldenhuys
to Unknown author
Show quoted text 5 lines
> Where in the Delphi documentation does it mention that? I couldn't find > any such reference in the Delphi 7 docs, and I thought FPC implements > behaviour based on documented behaviour, not implementation behaviour? Sure. See the 'CommaText' help.

Sure, that is the help for CommaText, not the help for Delimiter or DelimitedText. In the latter documentation it makes no mention of SDF (System Data Format) format usage - which apparently has the Comma or Space character requirement.

DelimitedText docs say: "individual strings are separated by the character specified by the Delimiter property."

I guess this boils down to the interpretation of the Delphi documentation then.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/
Unknown author
to Graeme Geldenhuys
Graeme Geldenhuys wrote 17 lines
On 2011-11-21 11:17, wrote: >> Where in the Delphi documentation does it mention that? I couldn't find >> any such reference in the Delphi 7 docs, and I thought FPC implements >> behaviour based on documented behaviour, not implementation behaviour? > > Sure. See the 'CommaText' help. Sure, that is the help for CommaText, not the help for Delimiter or DelimitedText. In the latter documentation it makes no mention of SDF (System Data Format) format usage - which apparently has the Comma or Space character requirement. DelimitedText docs say: "individual strings are separated by the character specified by the Delimiter property." I guess this boils down to the interpretation of the Delphi documentation then.

In my opinion, the Delphi documentation is quite explicit:

----------------------------------------------------------------------- When writing DelimitedText, individual strings must be separated using QuoteChar at both ends, using Delimiter as a separator, or using both these methods.

Note: CommaText is the same as the DelimitedText property when Delimiter is ',' and QuoteChar is '"'.
-----------------------------------------------------------------------

The first paragraph indicate that in fact you should always use " around your values.

And the last sentence should prompt anyone to go and read the CommaText docs.

But we're not here to discuss the merits/disadvantages of the Delphi docs :-)

Michael.

Graeme Geldenhuys
to Unknown author
But we're not here to discuss the merits/disadvantages of the Delphi docs :-)

Indeed. I double checked the FPC documentation, and it is perfectly clear and simple to understand. Makes me wonder why I even bothered to read the Delphi docs. :)

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/
Frank Church
to Unknown author: In my opinion, the Delphi documentation is quite explicit:…
Show quoted text 47 lines
On Mon, 21 Nov 2011, Graeme Geldenhuys wrote: On 2011-11-21 11:17, wrote: > >> Where in the Delphi documentation does it mention that? I couldn't find >>> any such reference in the Delphi 7 docs, and I thought FPC implements >>> behaviour based on documented behaviour, not implementation behaviour? >>> >> >> Sure. See the 'CommaText' help. >> > > Sure, that is the help for CommaText, not the help for Delimiter or > DelimitedText. In the latter documentation it makes no mention of SDF > (System Data Format) format usage - which apparently has the Comma or > Space character requirement. > > DelimitedText docs say: "individual strings are separated by the > character specified by the Delimiter property." > > I guess this boils down to the interpretation of the Delphi > documentation then. > In my opinion, the Delphi documentation is quite explicit: ------------------------------**------------------------------** ----------- When writing DelimitedText, individual strings must be separated using QuoteChar at both ends, using Delimiter as a separator, or using both these methods. Note: CommaText is the same as the DelimitedText property when Delimiter is ',' and QuoteChar is '"'. ------------------------------**------------------------------** ----------- The first paragraph indicate that in fact you should always use " around your values. And the last sentence should prompt anyone to go and read the CommaText docs.

This is one of the things concocted to make life difficult for programmers[?]. In my view if the docs are not explicit about space being treated specially, then it shouldn't be treated specially, but such are the conventions in the programming world.

Show quoted text 9 lines
But we're not here to discuss the merits/disadvantages of the Delphi docs :-) Michael. ______________________________**_________________ fpc-pascal maillist - http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal>
Frank Church ======================= http://devblog.brahmancreations.com
Unknown author
to Frank Church
Frank Church wrote 15 lines
On 21 November 2011 10:06, wrote: > > The first paragraph indicate that in fact you should always use " around > your > values. > > And the last sentence should prompt anyone to go and read the CommaText > docs. > > This is one of the things concocted to make life difficult for programmers[?]. In my view if the docs are not explicit about space being treated specially, then it shouldn't be treated specially, but such are the conventions in the programming world.

That is why the FPC docs are quite explicit:

http://www.freepascal.org/docs-html/rtl/classes/tstrings.delimitedtext.html

Michael.