TRIM command trims more than spaces

BlitzPlus Forums/BlitzPlus Programming/TRIM command trims more than spaces

WolRon(Posted 2006) [#1]
The TRIM command also trims what appears to be any character with an ASCII value less than 32 (such as Chr$(2) or Chr$(3)) from the string as well as leading/trailing spaces.

This appears to be undesired behavior (at least it is for me...) since the documentation doesn't mention anything about removing additional characters.

I haven't tried Blitz3D to see if it's the same behavior but I would assume it to be.

Does anyone else think this is undesirable? I think at the least, the documentation should be rewritten to include this information.


CS_TBL(Posted 2006) [#2]
hm.. I'd say the command is about 'text' .. text begins @ 32.
Shouldn't be hard to make your own TRIM function which leaves <32 in peace.. but what do you need all that for anyway?


Yan(Posted 2006) [#3]
I'm pretty sure the original (B2D) docs used the term 'white space', which is more correct.


WolRon(Posted 2006) [#4]
Shouldn't be hard to make your own TRIM function which leaves <32 in peace..
Which is what I'll do. I was just asking for everyone elses opinion on whether or not it should be that way.

but what do you need all that for anyway?
Because Chr$(34) ("") double quote characters can't be included in data statements, so I'm replacing them with Chr$(2) and Chr$(3) (which just show up as 'blocks' in the data statements) and then later replacing 2 and 3 with Chr$(34) (well actually 147 and 148).

I'm pretty sure the original (B2D) docs used the term 'white space', which is more correct.
But control characters aren't 'white space'...


CS_TBL(Posted 2006) [#5]
Can't you use an unused >32 char for doublequotes ~ [ ] etc. and do perform a 'Replace' on your freshly read string?


WolRon(Posted 2006) [#6]
Yes, but I'm accessing a 7000+ line database and I don't know what's all in it, so I don't want to possibly corrupt any of the data.


Yan(Posted 2006) [#7]
But control characters aren't 'white space'...
I suppose that depends upon your age and on which side of the pond you hail from... ;o)


Grey Alien(Posted 2006) [#8]
In Delphi Trim also removes #13 #10 combos (CR LF)