Mombu the Php Forum

Go Back   Mombu the Php Forum > Php > First stupid post of the year.
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
61 5th November 02:45
parasane
External User
 
Posts: 1
Default First stupid post of the year.



Why is it that things work perfectly for me until you test them?

--
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.
  Reply With Quote


 


62 5th November 02:45
lists
External User
 
Posts: 1
Default First stupid post of the year.



I just added the trim() part in the third box down.

AFAICT it works like it should. See for yourself.

http://www.cmsws.com/examples/html/form_encoding.php

Here is the output that I get with FF 2.0.0.11

_POST data is:
Name is submit
0000 A0 20 A0 20 43 6C 69 63 6B 20 4D 65 21 20 A0 20 ....Clic k.Me!...
0010 A0 .

What do you get?

--
Jim Lucas

"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare
  Reply With Quote
63 5th November 02:45
tedd.sperling
External User
 
Posts: 1
Default First stupid post of the year.


It's because I have a tester.

You see, it's easy to say "Nope, that don't work." But, it's much
harder to find a solution.

Finding a solution is usually best served when one doesn't under
estimate the problem, as many here have already demonstrated.

As it turns out, this problem is more complex than any of us has been
able to fathom thus far.

When a string containing non-breaking spaces is sent via a POST, what
do those non-breaking spaces become? It's clear that they are not
spaces, nor are they  

To find out, I did put the operation through FireFox and reversed the
POST/GET operations to get a look at the string -- it is:

%C2%A0%C2%A0%C2%A0Z%C2%A0%C2%A0%C2%A0 < where Z is the value passed.

Now, C2 (HEX) is a linefeed (194 DEC)

And, A0 (HEX) is a non-breaking space (160 DEC which is a &nbsp;

Therefore, if I simply use:

$submit = str_replace( chr(194), '', $submit );
$submit = str_replace( chr(160), '', $submit );

This is the solution.

Now, why does a POST operation add in C2's? I'll leave that for
another post. :-)

Thanks everyone for your time. I hope we all learned something, I did.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Reply With Quote
64 5th November 02:46
tedd
External User
 
Posts: 1
Default First stupid post of the year.


That depends upon what Text Encoding my browser is set to.

However, the point is moot. I just tried a variation of your code, namely:

$submit = trim($submit, "\xA0\xC2");

And it worked. So you were on the right track, just using the wrong HEX.

See my SOLVED post.

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Reply With Quote
65 5th November 02:47
parasane
External User
 
Posts: 1
Default First stupid post of the year.


Well, believe it or not, that was the highlight of my day, which
began with everything going wrong - not just normal, small things like
stubbing your toe, but rather larger - and culminated in my truck
burning up while I was driving to a datacenter for a client.

Now the research begins.... why DOES that C2 get thrown in?

P.S. - If someone has the answer, don't tell me, because I'd like
something to keep Wednesday off my mind for the rest of the week.

--
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.
  Reply With Quote
66 5th November 02:47
tedd
External User
 
Posts: 1
Default First stupid post of the year.


I didn't mean it that way. I meant for my current logic, I need the
value of the submit button to be 'A'. I have much more going on here
than just that. I have over 40 different values for the submit button
and a switch statement that uses what's submitted. I don't want to,
and see no reason to, change it.

Cheers,

tedd


--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Reply With Quote


 


67 8th November 03:47
news.nospam.0ixbtqke
External User
 
Posts: 1
Default First stupid post of the year.


Not quite. <A0> is non-breaking space in *some* character
encodings, such as the ISO-8859-... encodings. It may
be different in other encodings. In UTF-8, it is <C2 A0>,
which is exactly what you're seing.

I haven't had time to look at the code, but perhaps you
need to specify a character encoding for the page.


/Nisse
  Reply With Quote
68 8th November 03:48
tedd.sperling
External User
 
Posts: 1
Default First stupid post of the year.


Well considering that UTF-8 encompasses/includes all of the code
points found ISO-8859, then I think that both encodings would
reference the same character. After all, if they didn't then what's
the point of Unicode?

Now, one can argue how many bytes are needed to represent a character
in what encoding, but that doesn't change the character. In the end,
I believe that <A0> is the same regardless of what charset or
encoding you're using.

I just don't understand where C2 comes from or why it's there. I
would think that <00 A0> would be more appropriate.

If you mean my solution doesn't work, then you are mistaken -- for
works for me.

That's a valid point. Not only the encoding that's declared for the
page via it's html DOCTYPE, but also what encoding was used to
actually save that file on the server.

This entire encoding process is more involved than it looks, or so it
appears to me.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Reply With Quote
69 8th November 03:48
ceo
External User
 
Posts: 1
Default First stupid post of the year.


D'oh!

Of course &nbsp; in the browser is converted to a single character,
whose ASCII (extended ASCII, actually) value is 160.

trim() does not consider chr(160) as whitespace, unless you explicitly
add it in the second arg, along with the usual suspects.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
  Reply With Quote
70 8th November 03:48
ceo
External User
 
Posts: 1
Default First stupid post of the year.


http://www.l-i-e.com/a/

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
  Reply With Quote
Reply


Thread Tools
Display Modes




666