Page 1 of 1 1
Topic Options
#209902 - 2015-02-03 03:09 PM trim() does not work - 4.64
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
 Code:
$test=chr(10)+" some text "+chr(13)+chr(9)

'"' trim($test) '"'

get $


should produce "some text" but instead procudes garbage. unless me and every other language has a different meaning for what constitutes a space compared to Ruud's.


Edited by Lonkero (2015-02-04 07:02 PM)
_________________________
!

download KiXnet

Top
#209904 - 2015-02-04 12:32 PM Re: trim() does not work - 4.64 [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
I get the same results with all versions from 4.53 on up...

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#209905 - 2015-02-04 12:39 PM Re: trim() does not work - 4.64 [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Using the following:
 Code:
Break On
@KIX ??

$test=" some text "
? 'Spaces:' ?
'"' $test '"'

$test=" some text "+chr(9)
? 'Spaces + Tab:' ?
'"' $test '"'

$test=" some text "+chr(13)+chr(9) 
? 'Spaces, Tab, & CR' ?
'"' $test '"'

$test=chr(10)+" some text "+chr(13)+chr(9) 
? 'All Chars:' ?
'"' $test '"'
it becomes clear that only SPACES are dealt with by Trim(), not "Whitespace". The "garbage" you get is exactly what's expected when you move to a new line, remove spaces, print "some text" (9 characters" followed by a CR, then tab to position 8 - only the last "t" is left.

Per the manual, it says "spaces" and not "whitespace".

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#209907 - 2015-02-04 06:08 PM Re: trim() does not work - 4.64 [Re: Glenn Barnas]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I don't get it

there is no trim() in both of your code snippets

chr(10) = LF
chr(13) = CR
chr(9) = a TAB

too tired to run that atm

Oh, and how about '"' + $test + '"'



Edited by Jochen (2015-02-04 06:10 PM)
_________________________



Top
#209908 - 2015-02-04 06:21 PM Re: trim() does not work - 4.64 [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I don't know what I was thinking when I posted that...

fixed. imo, LF is a space. but I guess you are right as well, on strict sense it is only chr(32)


Edited by Lonkero (2015-02-04 07:03 PM)
_________________________
!

download KiXnet

Top
#209909 - 2015-02-04 10:46 PM Re: trim() does not work - 4.64 [Re: Lonkero]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
in historical means a line feed resembles a turn upwards on the round thing (dunno what it is called) on a typewriter .. so practically a vertical whitespace you mean?
_________________________



Top
#209910 - 2015-02-04 10:59 PM Re: trim() does not work - 4.64 [Re: Jochen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
It's called a "platen" \:\)
_________________________
Actually I am a Rocket Scientist! \:D

Top
#209934 - 2015-02-07 04:36 PM Re: trim() does not work - 4.64 [Re: Glenn Barnas]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ok,

just to verify what garbage means ... are your results the same as mine?

Note the cursor porsition also:


Attachments
347.png
Description:


_________________________



Top
#209936 - 2015-02-07 08:30 PM Re: trim() does not work - 4.64 [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
something is weird here. I got the same result on my laptop as you.
at work where I posted that I got:
 Code:
"
        "t


ok, back to giving you an example that actually has the issue...

it seems that kixtart processes tabs, linefeeds and spaces as spaces but not carriage returns, as witnessed by this simple test:
 Code:
$test=" some text "+@crlf

'"' trim($test) '"'

get $

here the result is exactly the same as with the original example.
the weird part comes that in my code that experienced issues, there was CRLF after a space and that space never got removed until I did join(split()) on all special characters. seems that dealing with the chr(13) would have been enough.
_________________________
!

download KiXnet

Top
#210409 - 2015-07-23 08:45 PM Re: trim() does not work - 4.64 [Re: Lonkero]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
...yep, another genuine bug in KiX ...

Good catch, this is fixed in the upcoming build.

Ruud

Top
Page 1 of 1 1


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 360 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.065 seconds in which 0.025 seconds were spent on a total of 14 queries. Zlib compression enabled.