Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-15 Thread Richard Lynch
On Sat, January 5, 2008 4:04 pm, Nisse Engström wrote:
 On Sat, 5 Jan 2008 01:08:13 -0500, tedd wrote:

 At 1:41 AM +0100 1/5/08, Nisse Engström wrote:
On Fri, 4 Jan 2008 09:16:54 -0500, tedd wrote:

  At 10:33 AM +0100 1/4/08, Nisse Engström wrote:
On Thu, 3 Jan 2008 12:39:36 -0500, tedd wrote:
NOTE: Richard Lynch tells us that (some versions of)
 Internet Explorer, under certain circumstances, ignore
 the `Content-Type:´ header and that a meta element is
 necessary to make it guess the encoding correctly. I
 don't know about this, but I tend to believe him.

I'm WAY behind on emails, but thought I'd chime in here, in case
somebody wants to try to find it...

I no longer have access to the SOAP service that was providing the
data that was causing the problem, so I can't give a URL that will
demonstrate this easily.

But I can add that the HTML output (required by my former boss) was SO
BAD that it didn't even begin to validate and was throwing IE into
quirks mode.

So, having a header() and being in quirks mode in IE 6 (5?) and not
having a META tag for the charset, and having mixed charsets (or
whatever they are) on a page was causing this issue.

The actual characters were a pronunciation guide to Medici as well
as having Medici written with diacritial marks in another part of
the page.

You can snag the output from answers.com (the provider of
no-longer-available SOAP service) if you really want to play with
this.

Then you'd have to wrap their content up in some truly disgusting
non-validating HTML and re-present it as your own content.

Putting in the META tag forced IE to use UTF-8 and make it work.

-- 
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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-09 Thread Nisse Engström
On Mon, 7 Jan 2008 10:29:45 -0500, tedd wrote:

 At 12:03 PM +0100 1/7/08, Nisse Engström wrote:
How does the following pages compare? The display
should be identical:

http://luden.se/test/t-1252.html
http://luden.se/test/t-utf8.html
 
 Nisse:
 
 No, there is quite a difference depending upon 
 the text encoding used in my browser (Safari).

   You said that there was no windows-1252 setting
in Safari, so I am curious to know if it is capable
of mapping the 1252-encoded page to the correct
characters. If you set your browser to detect the
encoding *automatically*, does the two pages display
identically, or are there differences?

   According to the mappings at unicode.org, there
are a lot of difference between MACROMAN and CP1252,
for instance, the first character on the page (0x80)
is A-DIARESIS in MACROMAN and EURO SIGN in 1252.


/Nisse

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-09 Thread tedd

At 1:19 PM +0100 1/9/08, Nisse Engström wrote:

On Mon, 7 Jan 2008 10:29:45 -0500, tedd wrote:


 At 12:03 PM +0100 1/7/08, Nisse Engström wrote:

How does the following pages compare? The display
should be identical:


 http://luden.se/test/t-1252.html
 http://luden.se/test/t-utf8.html


 Nisse:

 No, there is quite a difference depending upon
 the text encoding used in my browser (Safari).


   You said that there was no windows-1252 setting
in Safari, so I am curious to know if it is capable
of mapping the 1252-encoded page to the correct
characters. If you set your browser to detect the
encoding *automatically*, does the two pages display
identically, or are there differences?

   According to the mappings at unicode.org, there
are a lot of difference between MACROMAN and CP1252,
for instance, the first character on the page (0x80)
is A-DIARESIS in MACROMAN and EURO SIGN in 1252.


Nisse:

Yes, I said that there is no windows-1252 
setting for Safari. It does not offer that 
named setting in it's list of text encodings 
available. There is no 1252 mentioned either -- 
however, that does not mean that it's not there 
under a different name. Understandably, I don't 
think Apple wants to use the term windows in 
it's list of text encodings.


There is no Automatic setting. You set whatever 
you want the default to be and that's it.


The:

http://luden.se/test/t-utf8.html

looks good ONLY under UTF-8 setting.

The:

http://luden.se/test/t-1252.html

looks good ONLY under Western (ISO Latin 1).

If I use Western (Mac OS Roman) there is 
considerable difference, but it's not gibberish.


HTH's

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-09 Thread Nisse Engström
On Wed, 9 Jan 2008 10:30:59 -0500, tedd wrote:

 Yes, I said that there is no windows-1252 
 setting for Safari. It does not offer that 
 named setting in it's list of text encodings 
 available. There is no 1252 mentioned either -- 
 however, that does not mean that it's not there 
 under a different name. Understandably, I don't 
 think Apple wants to use the term windows in 
 it's list of text encodings.
 
 There is no Automatic setting. You set whatever 
 you want the default to be and that's it.

Interesting. Would you be kind enough to compare
the following pages (with meta headers):

   http://luden.se/test/charmap/1252-1252-m.html
   http://luden.se/test/charmap/1252-utf8-m.html

For what it's worth, the pages look identical when
viewed with Browsrcamp[1], both with and without[2]
meta headers.


/Nisse

  -   -   -  

[1]: http://www.browsrcamp.com/
[2]: http://luden.se/test/charmap/1252-1252-t.html
 http://luden.se/test/charmap/1252-utf8-t.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-08 Thread Zoltán Németh
2008. 01. 7, hétfő keltezéssel 12.14-kor tedd ezt írta:
 At 4:36 PM +0100 1/7/08, Zoltán Németh wrote:
 2008. 01. 7, hétf‘ keltezéssel 10.29-kor tedd ezt írta:
 however, on firefox with encoding auto-detection both page looks
 correctly and the same.
 
 greets
 Zoltán Németh
 
 Not that you are claiming otherwise, but FF will 
 render the pages incorrectly if the text encoding 
 isn't correctly set -- and that's the point.
 
 Look at this in FF with text encoding set to ISO-8859:
 
 http://luden.se/test/t-utf8.html
 

sure. if you force an encoding on FF, you will sooner or later meet
pages which will look as garbage because they use another encoding.
however if FF is set to auto-detect encoding AND the page sends the
correct header/meta tag info, the page is usually displayed correctly.

greets
Zoltán Németh

 Cheers,
 
 tedd
 
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-07 Thread Nisse Engström
On Sun, 6 Jan 2008 11:28:55 -0500, tedd wrote:

 At 11:04 PM +0100 1/5/08, Nisse Engström wrote:

The page encoding is determined by the HTTP
`Content-Type:´ header. Period. A meta element
may provide hints to a browser if the HTTP header
is missing (eg. when saving a page to disc). In the
presence of a `Content-Type:´ header, the meta
element should be completely ignored.
 
 So, if one uses this --
 
 ?php header('Content-Type: text/css; charset=UTF-8'); ?

[text/html ?]

 -- preceding everything else on a web page, and 
 also saves that page using UTF-8 encoding, then 
 it's certain that the page will be recognized as 
 UTF-8 across all modern browsers?

   I don't know if there is any certainty. If you want
absolute certainty, plain ASCII with character references
(`Auml;´, `#x201d´ and so on) may be the way to go.
And even then, all character references might not be
supported by the browser...

   And lastly, what's the best encoding to set your
  browser? I have clients who are all over the
  place with special windoze characters that appear
  like garbage in my browser.

Set it to detect automatically, with a preference
for cp1252 (or windows-1252) which covers a lot of
western characters. cp1252 also has the nice property
of being compatible with ISO-8859-1, except that it
has some extra real characters where 8859-1 has control
characters.
 
 Interesting that my browser (Safari) doesn't even 
 offer that choice, at least under that name. It 
 does offer ISO Latin, Mac OS Roman, UTF-8, and 34 
 other language-specific text encodings -- but not 
 1252.

[The proper name is `windows-1252´.]

How does the following pages compare? The display
should be identical:

http://luden.se/test/t-1252.html
http://luden.se/test/t-utf8.html


/Nisse

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-07 Thread tedd

At 12:03 PM +0100 1/7/08, Nisse Engström wrote:

How does the following pages compare? The display
should be identical:

http://luden.se/test/t-1252.html
http://luden.se/test/t-utf8.html


Nisse:

No, there is quite a difference depending upon 
the text encoding used in my browser (Safari).


For example, using UTF-8

http://luden.se/test/t-1252.html

produces nothing but repeating ?  (black diamond with question mark).

Where as:

http://luden.se/test/t-utf8.html

Shows all the code-points correctly.

---

Using Western (ISO Latin 1)

http://luden.se/test/t-1252.html

is correct, but

http://luden.se/test/t-utf8.html

is gibberish.


---
Using Western (Mac OS Roman)

http://luden.se/test/t-1252.html

is almost correct (it has an Apple logo).

and

http://luden.se/test/t-utf8.html

is gibberish.

--

So, the browser wars move on to text encoding.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-07 Thread Zoltán Németh
2008. 01. 7, hétfő keltezéssel 10.29-kor tedd ezt írta:
 At 12:03 PM +0100 1/7/08, Nisse Engström wrote:
 How does the following pages compare? The display
 should be identical:
 
 http://luden.se/test/t-1252.html
 http://luden.se/test/t-utf8.html
 
 Nisse:
 
 No, there is quite a difference depending upon 
 the text encoding used in my browser (Safari).
 
 For example, using UTF-8
 
 http://luden.se/test/t-1252.html
 
 produces nothing but repeating ?  (black diamond with question mark).
 
 Where as:
 
 http://luden.se/test/t-utf8.html
 
 Shows all the code-points correctly.
 
 ---
 
 Using Western (ISO Latin 1)
 
 http://luden.se/test/t-1252.html
 
 is correct, but
 
 http://luden.se/test/t-utf8.html
 
 is gibberish.
 
 
 ---
 Using Western (Mac OS Roman)
 
 http://luden.se/test/t-1252.html
 
 is almost correct (it has an Apple logo).
 
 and
 
 http://luden.se/test/t-utf8.html
 
 is gibberish.
 
 --

however, on firefox with encoding auto-detection both page looks
correctly and the same.

greets
Zoltán Németh

 
 So, the browser wars move on to text encoding.
 
 Cheers,
 
 tedd
 
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-07 Thread Robert Cummings
All of these look the same for me in Opera under Linux. Character sets
are not a browser war issue, they're a character set/font issue. Just
because a character set supports a character, doesn't mean the character
font exists.

Cheers,
Rob.


On Mon, 2008-01-07 at 10:29 -0500, tedd wrote:
 At 12:03 PM +0100 1/7/08, Nisse Engström wrote:
 How does the following pages compare? The display
 should be identical:
 
 http://luden.se/test/t-1252.html
 http://luden.se/test/t-utf8.html
 
 Nisse:
 
 No, there is quite a difference depending upon 
 the text encoding used in my browser (Safari).
 
 For example, using UTF-8
 
 http://luden.se/test/t-1252.html
 
 produces nothing but repeating ?  (black diamond with question mark).
 
 Where as:
 
 http://luden.se/test/t-utf8.html
 
 Shows all the code-points correctly.
 
 ---
 
 Using Western (ISO Latin 1)
 
 http://luden.se/test/t-1252.html
 
 is correct, but
 
 http://luden.se/test/t-utf8.html
 
 is gibberish.
 
 
 ---
 Using Western (Mac OS Roman)
 
 http://luden.se/test/t-1252.html
 
 is almost correct (it has an Apple logo).
 
 and
 
 http://luden.se/test/t-utf8.html
 
 is gibberish.
 
 --
 
 So, the browser wars move on to text encoding.
 
 Cheers,
 
 tedd
 
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-07 Thread tedd

At 4:36 PM +0100 1/7/08, Zoltán Németh wrote:

2008. 01. 7, hétf‘ keltezéssel 10.29-kor tedd ezt írta:
however, on firefox with encoding auto-detection both page looks
correctly and the same.

greets
Zoltán Németh


Not that you are claiming otherwise, but FF will 
render the pages incorrectly if the text encoding 
isn't correctly set -- and that's the point.


Look at this in FF with text encoding set to ISO-8859:

http://luden.se/test/t-utf8.html

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-07 Thread tedd

At 10:41 AM -0500 1/7/08, Robert Cummings wrote:
Character setsare not a browser war issue, 
they're a character set/font issue. Just

because a character set supports a character, doesn't mean the character
font exists.

Cheers,
Rob.


Rob:

What I meant by browser wars was that there is 
a different between how browsers render different 
text encodings -- this is a fact -- there is a 
difference. For example, the Extended ASCII 
codes (never approved by ASCII) shows many 
characters differently depending on browser 
encoding. Apple even has it's own logo appearing 
for DEC 240 (F0 HEX) for it's encoding. I can 
provide even more examples of differences if 
necessary, but one should be enough.


Additionally, browsers absolutely render urls 
differently depending on encoding. Just look at 
the IDNS  encoding PUNYCODE for that -- here's 
proof:


http://xn--19g.com

In Safari (both Mac and Windows) the url will be 
shown as ˆ.com (square root dot dom) whereas in 
IE (all versions) it will be show in PUNYCODE, 
namely xn--19g.com


Note -- both OS's clearly have the square root 
symbol in their font set. So this is NOT an issue 
of IF the character exist within the font 
(charset) because the character IS present.


I know the reasons behind their decisions to do 
what they did, but the fact remains there is a 
difference, as I said.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-06 Thread tedd

At 11:04 PM +0100 1/5/08, Nisse Engström wrote:


   The page encoding is determined by the HTTP
`Content-Type:´ header. Period. A meta element
may provide hints to a browser if the HTTP header
is missing (eg. when saving a page to disc). In the
presence of a `Content-Type:´ header, the meta
element should be completely ignored.


So, if one uses this --

?php header('Content-Type: text/css; charset=UTF-8'); ?

-- preceding everything else on a web page, and 
also saves that page using UTF-8 encoding, then 
it's certain that the page will be recognized as 
UTF-8 across all modern browsers?




  And lastly, what's the best encoding to set your

 browser? I have clients who are all over the
 place with special windoze characters that appear
 like garbage in my browser.


   Set it to detect automatically, with a preference
for cp1252 (or windows-1252) which covers a lot of
western characters. cp1252 also has the nice property
of being compatible with ISO-8859-1, except that it
has some extra real characters where 8859-1 has control
characters.


Interesting that my browser (Safari) doesn't even 
offer that choice, at least under that name. It 
does offer ISO Latin, Mac OS Roman, UTF-8, and 34 
other language-specific text encodings -- but not 
1252.


Besides, while I know that the majority of 
Internet users are windows challenged, I can't 
bring myself to follow -- I'll stick with UTF-8. 
:-)


Side note: Hopefully some day soon, M$ will stop 
treating the global user as a 
second-class-citizen in using PUNYCODE instead of 
displaying characters (code-points) as intended 
by the IDNS. I think the homographic attack 
concern is basically a red herring that could be 
easily solved (if it was really a problem) by 
simply color coding mixed charset urls. Would 
work for me.


I find it interesting that Safari doesn't show 
PUNYCODE and the majority of Apple's profits came 
from other than US sources last year -- perhaps 
this is a result of end-user sensitivity. It's 
nice to know that when everything else fails, 
money always seems to work. :-)


In any event, thank again for your thoughts.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-05 Thread Nisse Engström
On Sat, 5 Jan 2008 01:08:13 -0500, tedd wrote:

 At 1:41 AM +0100 1/5/08, Nisse Engström wrote:
On Fri, 4 Jan 2008 09:16:54 -0500, tedd wrote:

  At 10:33 AM +0100 1/4/08, Nisse Engström wrote:
On Thu, 3 Jan 2008 12:39:36 -0500, tedd wrote:

   Nisse:
 
 Thanks again for your time and guidance.

   If that's what you want to call my incoherent
ramblings... :-)

 As you said, it's my understanding that a web 
 page encoding can be designated via a meta 
 statement
 
 meta http-equiv=content-type content=text/html;charset=UTF-8

   The page encoding is determined by the HTTP
`Content-Type:´ header. Period. A meta element
may provide hints to a browser if the HTTP header
is missing (eg. when saving a page to disc). In the
presence of a `Content-Type:´ header, the meta
element should be completely ignored.

   There have been reports about russian servers that
transcode document from one encoding to another (and
modifies the HTTP headers accordingly) on the fly,
which means that the meta element is incorrect when
it reaches the browser.

   NOTE: Richard Lynch tells us that (some versions of)
Internet Explorer, under certain circumstances, ignore
the `Content-Type:´ header and that a meta element is
necessary to make it guess the encoding correctly. I
don't know about this, but I tend to believe him.

   You should probably do what Richard says.

 However, that might be different than how the page was actually saved.
 
 I have heard of instances where a disconnect like 
 that has caused problems with browsers and made 
 them kick into quirks mode, which also has 
 affected other things like javascript. I had one 
 javascript guru that kept hitting me over the 
 head with complaints that I was deliberately 
 doing it just to piss him off, but the truth was 
 I just didn't realize the problem -- still don't.

   Things like that can probably happen.

 So, to cover all bases -- what's the best way to 
 set encoding in web page, to save correctly and 
 use a meta tag? And, what do you recommend to be 
 the best encoding to shoot for, UTF-8?

   UTF-8.

   The only character encodings that seem to be universally
supported (if I recall correctly) are most ISO-8859 (eg
`ISO-8859-1´) and Windows (eg. `cp1252´) encodings, and
UTF-8. The advantage of UTF-8 is, of course, that it
covers *a lot* more characters than any of the legacy
8-bit encodings.

   I think that support for UTF-16 (and UTF-32) is
lacking, especially when it comes to form submission.

   UTF-8 also has some very nice properties:

* Compatibility with ASCII. Even though it is a variable-
  length encoding, all ASCII characters (U+00 - U+7f)
  have identical encodings in ASCII and UTF-8.
* Compatibility with 8-bit string functions. All multi-
  octet sequences (U+80 and up) contain only octets in
  the range 80 - ff, so there are no NULL or control
  characters embedded that can cause problems. Even
  string comparison works (unless you want to go whole
  hog with combining characters, character collation
  and what-not).
* (And some more stuff that I'm too tired to remember.)

 And lastly, what's the best encoding to set your 
 browser? I have clients who are all over the 
 place with special windoze characters that appear 
 like garbage in my browser.

   Set it to detect automatically, with a preference
for cp1252 (or windows-1252) which covers a lot of
western characters. cp1252 also has the nice property
of being compatible with ISO-8859-1, except that it
has some extra real characters where 8859-1 has control
characters.

   I seems to me that when a page is served with an
incorrect encoding or none at all, cp1252 is often
the correct encoding. Of course, that may depend on
which pages I tend to visit...

   This doesn't always work of course; Regardless of
what you choose, you can probably find plenty of pages
where that choice is wrong. Both Opera and FireFox will
let you choose encoding on the fly through the menu bar.

  -   -   -  

   And sometimes you can stumble upon a page where
*every* choice is wrong:

http://www.w3.org/International/

Look at the various languages under Links to Translation
in the yellowish column. Under ar (Arabic) you'll find
the following characters (in UTF-8):

   c3 98c2 a7c3 99c2 84c3 98c2 b9c3 98
   c2 b1c3 98c2 a8c3 99c2 8ac3 98c2 a9

Run this through a `UTF-8 to UTF-16´ converter (to make
the Unicode code points easier to read) and you'll find:

   00 d800 a700 d900 8400 d800 b900 d8
   00 b100 d800 a800 d900 8a00 d800 a9

Now, lose the zeroes...

   d8 a7d9 84d8 b9d8 b1d8 a8d9 8ad8 a9

...and run it *again* through the `UTF-8 to UTF-16´
converter...

   06 2706 4406 3906 3106 2806 4a06 29

...and you end up with some actual arabic characters!
(The range U+0600 - U+06ff contain arabic characters.)
It's the same for the other languages.

And this on a page about internationalization no less. :-)

 I read a book on Unicode and the book provided 
 considerable evidence of the complexities of 
 encoding. Now 

Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-05 Thread Daniel Brown
On Jan 5, 2008 5:04 PM, Nisse Engström [EMAIL PROTECTED] wrote:
[snip!]
The page encoding is determined by the HTTP
 `Content-Type:´ header. Period.
[snip=again]

Negative.  If that were the case, what would be the sense in
providing browser encoding translation?  Have you noticed, for
example, that Opera and Firefox (read: any browser other than Internet
Exploder) provide the opportunity for viewing in alternate UTFs, et
cetera?

I'm not saying you're entirely wrong, but it's not an
all-encapsulating answer to say that all page encoding (which I'll
read as data served) will be determined by the HTTP (which is
actually only a protocol, by the way) 'Content-type' header.

Regardless, interpretation will be done by the client.
Versioning, for example, proves that the Content-type header is not
the end-all, be-all.  Grabbing a file via wget 1.3 may give (again,
*may give*, this is unchecked ;-P ) a different result than Netscape
Navigator 2.4. From there, the filters (where necessary) argue over
how the format is handled.

-- 
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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-04 Thread Nisse Engström
On Thu, 3 Jan 2008 12:39:36 -0500, tedd wrote:

 At 4:24 PM +0100 1/3/08, Nisse =?utf-8?Q?Engstr=C3=B6m?= wrote:
On Wed, 2 Jan 2008 19:36:56 -0500, tedd wrote:

  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)

By the way, C2 is not a linefeed as far as I know.

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

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.
 
 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.

   You have a point here: the character is the same. In
Unicode it is called U+00A0. But Unicode alone does not
tell you how to represent the character in bytes. You
need an encoding for this.

   Unicode specifies a few different encodings, called
transformation formats (the T and F in UTF). The actual
bytes representing U+00A0 are as follows:

  UTF-32:   00 00 00 A0
  UTF-16BE: 00 A0
  UTF-16LE: A0 00
  UTF-8:C2 A0

(where the xx ... syntax denotes *byte* sequences.
 A byte sequence and a character are different things.)

   The fact that the byte A0 occurs in UTF-8 is just
an interesting, and easily confusing, coincident.

   In other encodings, the character U+00A0 may be
encoded differently. For example, in CP850 for DOS,
U+00A0 is encoded using the single byte ff.

  -   -   -  

   In HTML, there are a few ways to encode U+00A0. If
you have specified a character encoding for the document,
you can use the encoded character directly. You can
specify the encoding in HTTP (preferable) using PHP:

header ('Content-Type: text/html; charset=utf-8')

or .htaccess files (Apache 2):

AddDefaultCharset utf-8

Richard Lynch would tell you to also use a meta element:

meta http-equiv=Content-Type
  content=text/html; charset=utf-8


   If you don't want, or can't, use the encoded character
directly, you can also use HTML character references, such
as `nbsp;´, `#160´ or `#x00a0´. Numerical character
references *always* refer to Unicode characters, *regardless*
of the encoding used in the document. For example, if your
document is encoded in CP850, you would use `#xa0´ and not
`#xff´ to represent U+00A0.


  -   -   -  

   But let's go back to your problem again:
 
 I just don't understand where C2 comes from or why it's there. I 
 would think that 00 A0 would be more appropriate.

   When your document (web page) doesn't specify which
character encoding it is using, the browser will have to
guess. Many browser will use cp1252 or similar. Others
might use UTF-8, or inspect the document and guess which
is more apropriate. Some browsers can be configured to
prefer a particular encoding.

   When the form is submitted, the form control values
are encoded using whichever character encoding the
browser has settled on. If your browser has settled on
UTF-8, the `nbsp;´ in your form will be sent as C2 A0,
because character references can only be used in the HTML
document. In URLs they are encoded using numerical
references (eg. %C2%A0).

   And here's what is going wrong: Your server side
script is expecting the form submission to be encoded
in an single-byte encoding (such as cp1252 or iso-8859-1
or similar). The sequence %C2%A0 is interpreted as two
character rather than one character.

   Which two character would that be then? Well that,
again, depends on which character encoding your script
expects from the form submission:

  EncodingCharacters
  --
  iso-8859-1: U+00C2, U+00A0 (A-circumflex, nbsp)
  cp850:  U+252C, U+00E1 (box drawing character, a-acute)
  cp1252: U+00C2, U+00A0 (A-circumflex, nbsp)
  cp874:  U+0E22, U+00A0 (Thai YO YAK, nbsp)
  KSC5601:U+D63B (Hangul HIEUH-O-KIYEOKSIOS)

   Therefore, if I simply use:

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

  This is the solution.

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

 ``This seems to work but I really have no idea what's
   going on, so I'll just make random guesses´´

is very far from *the* solution in my mind.  :-)

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

More reading in no particular order:

The Unicode Standard:

Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-04 Thread tedd

At 10:33 AM +0100 1/4/08, Nisse Engström wrote:

On Thu, 3 Jan 2008 12:39:36 -0500, tedd wrote:


Nisse:

I thank you for your most enlightened and informative reply.

I cut/pasted your post into my list of things to remember.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-04 Thread Jürgen Wind


tedd-2 wrote:
 
 At 3:28 PM -0600 1/3/08, Richard Lynch wrote:
On Wed, January 2, 2008 5:26 pm, tedd wrote:
  At 2:34 PM -0800 1/2/08, Jim Lucas wrote:
This I think shows what tedd is looking for.

so, from this I deduce that this should work.

$submit = trim($submit, \xA0\x20);

What do you guys/gals think?

  Nope, not a winner. But it produces some interesting results.

http://www.l-i-e.com/a/
 
 
 That's neat.
 
 Cheers,
 
 tedd
 
FYI: 
output of http://www.l-i-e.com/a/ in 
SeaMonkey (Gecko, ),FF, default Char.encoding:Western ISO 8859-1 or UTF-8,
IE:
$_POST[a]: ' A '
0:   (160)
1: (32)
2:   (160)
3: (32)
4:   (160)
5: A (65)
6:   (160)
7: (32)
8:   (160)
9: (32)
10:   (160)
str_replace: ' A '
trim: 'A'

Opera 9.5beta (iso 8859-1 or utf-8)
$_POST[a]: ' A '
0: (32)
1: (32)
2: (32)
3: (32)
4: (32)
5: A (65)
6: (32)
7: (32)
8: (32)
9: (32)
10: (32)
str_replace: ' A '
trim: 'A'

Safari 3.0.4 (UTF-8)
$_POST[a]: ' A '
0: � (194)
1: � (160)
2: (32)
3: � (194)
4: � (160)
5: (32)
6: � (194)
7: � (160)
8: A (65)
9: � (194)
10: � (160)
11: (32)
12: � (194)
13: � (160)
14: (32)
15: � (194)
16: � (160)
str_replace: ' A '
trim: ' A�'

Safari 3.0.4 (Westeuropäisch)
$_POST[a]: 'Â  Â  Â AÂ  Â  Â '
0: Â (194)
1:   (160)
2: (32)
3: Â (194)
4:   (160)
5: (32)
6: Â (194)
7:   (160)
8: A (65)
9: Â (194)
10:   (160)
11: (32)
12: Â (194)
13:   (160)
14: (32)
15: Â (194)
16:   (160)
str_replace: 'Â  Â  Â AÂ  Â  Â '
trim: 'Â  Â  Â AÂ  Â  Â'

(all on w2k)

(my humble) conclusion: 

if('A'==$_POST['a'][5] or 'A'==$_POST['a'][8]) {
//do stuff
}

or some such is what you need

Jürgen
-- 
View this message in context: 
http://www.nabble.com/First-stupid-post-of-the-year.-tp14583639p14617982.html
Sent from the PHP - General mailing list archive at Nabble.com.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-04 Thread Web Design Company

Read google!

-
http://ooyes.net Web design company  |  http://ooyes.net Graphic design
company  |  http://ooyes.net Outsourcing company  
-- 
View this message in context: 
http://www.nabble.com/First-stupid-post-of-the-year.-tp14583639p14618938.html
Sent from the PHP - General mailing list archive at Nabble.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-04 Thread Daniel Brown
On Jan 4, 2008 10:39 AM, Web Design Company
[EMAIL PROTECTED] wrote:

 Read google!

No!

-- 
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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-04 Thread tedd

At 7:39 AM -0800 1/4/08, Web Design Company wrote:

Read google!


New to this list, are you?

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-04 Thread tedd

At 6:55 AM -0800 1/4/08, Jürgen Wind wrote:


FYI:
output of http://www.l-i-e.com/a/ in
SeaMonkey (Gecko, ),FF, default Char.encoding:Western ISO 8859-1 or UTF-8,
IE:
$_POST[a]: ' A '
0:   (160)
1: (32)
2:   (160)
3: (32)
4:   (160)
5: A (65)
6:   (160)
7: (32)
8:   (160)
9: (32)
10:   (160)
str_replace: ' A '
trim: 'A'

Opera 9.5beta (iso 8859-1 or utf-8)
$_POST[a]: ' A '
0: (32)
1: (32)
2: (32)
3: (32)
4: (32)
5: A (65)
6: (32)
7: (32)
8: (32)
9: (32)
10: (32)
str_replace: ' A '
trim: 'A'

Safari 3.0.4 (UTF-8)
$_POST[a]: ' A '
0: ? (194)
1: ? (160)
2: (32)
3: ? (194)
4: ? (160)
5: (32)
6: ? (194)
7: ? (160)
8: A (65)
9: ? (194)
10: ? (160)
11: (32)
12: ? (194)
13: ? (160)
14: (32)
15: ? (194)
16: ? (160)
str_replace: ' A '
trim: ' A?'

Safari 3.0.4 (Westeuropäisch)
$_POST[a]: 'Â  Â  Â AÂ  Â  Â '
0: Â (194)
1:   (160)
2: (32)
3: Â (194)
4:   (160)
5: (32)
6: Â (194)
7:   (160)
8: A (65)
9: Â (194)
10:   (160)
11: (32)
12: Â (194)
13:   (160)
14: (32)
15: Â (194)
16:   (160)
str_replace: 'Â  Â  Â AÂ  Â  Â '
trim: 'Â  Â  Â AÂ  Â  Â'

(all on w2k)

(my humble) conclusion:

if('A'==$_POST['a'][5] or 'A'==$_POST['a'][8]) {
//do stuff
}

or some such is what you need

Jürgen


Ahhh, I understand better now.

Humble conclusion or not, your investigation was impressive.

Thanks,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-04 Thread Nisse Engström
On Fri, 4 Jan 2008 09:16:54 -0500, tedd wrote:

 At 10:33 AM +0100 1/4/08, Nisse Engström wrote:
On Thu, 3 Jan 2008 12:39:36 -0500, tedd wrote:
 
 Nisse:
 
 I thank you for your most enlightened and informative reply.
 
 I cut/pasted your post into my list of things to remember.

A few more random thoughts on form submission:

   How does the browser know which character encoding
to use in the form submission? Well, lacking any other
guidance, I believe most browsers tend to use the
encoding that was used in the document where the form
is located.

   So what guidance can you give to the browser? The
form element has an attribute `accept-charset´ that
can be used to specify a list of acceptable character
encodings. However, something in the back of my mind
tells me I've read that this is not widely supported
by browsers, but I could easily be wrong about this.
In any case, a browser can choose a different encoding
if none of those specified are supported.

  [The name `accept-charset´ is somewhat unfortunate
because it confuses two different concepts: A character
set is a repertoire of characters, while a character
encoding is a way to translate (serialize) the
characters into a byte sequence. UTF-8 and UTF-16 both
contain the same character set (Unicode), but they
encode them in very different ways.]


   The general rule seems to be: Browsers tend to use
the same character encoding that it received from the
server.

   This brings up another problem: How do you *know*
which character encoding was actually used? Apparently,
this problem was overlooked when the HTTP protocol was
devised. The only way (according to the HTML spec. is
to use a POST request with enctype=multipart/form-data,
but I don't think PHP makes the Content-Type information
available to the user, so this is no help.

   Someone (Ian Hickson?) came up with a fix for this:
If you add the following form control:

  input type=hidden name=_charset_

most modern browsers will fill in which encoding it used
in the form submission.

  -   -   -  

More reading:

W3C on Internationalization:
http://www.w3.org/International/
(Even experts get it wrong. Spot the bug!)
W3C on character sets and encodings:
http://www.w3.org/International/getting-started/characters
Wikipedia on Character encoding:
http://en.wikipedia.org/wiki/Character_encoding



  This entire encoding process is more involved
   than it looks


/Nisse

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-04 Thread tedd

At 1:41 AM +0100 1/5/08, Nisse Engström wrote:

On Fri, 4 Jan 2008 09:16:54 -0500, tedd wrote:


 At 10:33 AM +0100 1/4/08, Nisse Engström wrote:

On Thu, 3 Jan 2008 12:39:36 -0500, tedd wrote:



  Nisse:


Thanks again for your time and guidance.

As you said, it's my understanding that a web 
page encoding can be designated via a meta 
statement


meta http-equiv=content-type content=text/html;charset=UTF-8

However, that might be different than how the page was actually saved.

I have heard of instances where a disconnect like 
that has caused problems with browsers and made 
them kick into quirks mode, which also has 
affected other things like javascript. I had one 
javascript guru that kept hitting me over the 
head with complaints that I was deliberately 
doing it just to piss him off, but the truth was 
I just didn't realize the problem -- still don't.


So, to cover all bases -- what's the best way to 
set encoding in web page, to save correctly and 
use a meta tag? And, what do you recommend to be 
the best encoding to shoot for, UTF-8?


And lastly, what's the best encoding to set your 
browser? I have clients who are all over the 
place with special windoze characters that appear 
like garbage in my browser.




  This entire encoding process is more involved
   than it looks


That sounds familiar.

I read a book on Unicode and the book provided 
considerable evidence of the complexities of 
encoding. Now throw into the mix PUNYCODE for 
IDNS and you have quite an assortment of problems 
with rendering different code-points in different 
char-sets. A very interesting topic.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-03 Thread Nisse Engström
On Wed, 2 Jan 2008 19:36:56 -0500, tedd wrote:

 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;

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.

 Therefore, if I simply use:
 
 $submit = str_replace( chr(194), '', $submit );
 $submit = str_replace( chr(160), '', $submit );
 
 This is the solution.

Hardly.

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

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


/Nisse

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-03 Thread tedd

At 4:24 PM +0100 1/3/08, Nisse =?utf-8?Q?Engstr=C3=B6m?= wrote:

On Wed, 2 Jan 2008 19:36:56 -0500, tedd wrote:


 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;


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.


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.



  Therefore, if I simply use:


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

 This is the solution.


Hardly.


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




  Now, why does a POST operation add in C2's?  I'll leave that for

 another post. :-)


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



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-03 Thread Richard Lynch
On Wed, January 2, 2008 5:26 pm, tedd wrote:
 At 2:34 PM -0800 1/2/08, Jim Lucas wrote:
This I think shows what tedd is looking for.

so, from this I deduce that this should work.

$submit = trim($submit, \xA0\x20);

What do you guys/gals think?

 Nope, not a winner. But it produces some interesting results.

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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-03 Thread Richard Lynch
On Wed, January 2, 2008 3:07 pm, Daniel Brown wrote:
 On Jan 2, 2008 3:58 PM, Richard Lynch [EMAIL PROTECTED] wrote:
 Works for me:

 [EMAIL PROTECTED] ~/cd $ php -a
 Interactive mode enabled

 ?php
 $a = 'nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;';
 $b = str_replace('nbsp;', '', $a);
 echo b: $b\n\n;
 $c = trim($b);
 echo c: $c\n\n;
 ?
 b:A

 c: A

 Tedd's problem is that it's not working on the web, though, Rich.
 I tested mine and it worked fine from the CLI, too, but not when
 encoded and then decoded via HTTP.

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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-03 Thread Richard Lynch
On Thu, January 3, 2008 11:39 am, tedd wrote:
 At 4:24 PM +0100 1/3/08, Nisse Engström wrote:
On Wed, 2 Jan 2008 19:36:56 -0500, tedd wrote:

  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;

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.

 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.

   Therefore, if I simply use:

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

  This is the solution.

Hardly.

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


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

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


 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.

Perhaps you should be taking a whitelist approach to filtering input?...

:-)

In other words, only allow specific characters combinations you expect
to see, and ignore any other goofy characters that were encoded from
nbsp;

Or, possibly, try using just spaces and not nbsp; for the value -- I
suspect that the browsers will NOT collapse the spaces in the VALUE
since it's data, not HTML content...

-- 
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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-03 Thread Richard Lynch
On Wed, January 2, 2008 6:36 pm, tedd wrote:
 Now, why does a POST operation add in C2's?  I'll leave that for
 another post. :-)

I believe the POST operation adds nothing.

The BROWSER interprets your nbsp; as whatever it finds most
appropriate to slap into a button VALUE, given the charset and
whatever the browser thinks it should do with that.

nbsp; probably shouldn't be part of a VALUE for a SUBMIT INPUT in the
first place, really...

-- 
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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-03 Thread tedd

At 3:35 PM -0600 1/3/08, Richard Lynch wrote:

On Wed, January 2, 2008 6:36 pm, tedd wrote:

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


I believe the POST operation adds nothing.

The BROWSER interprets your nbsp; as whatever it finds most
appropriate to slap into a button VALUE, given the charset and
whatever the browser thinks it should do with that.

nbsp; probably shouldn't be part of a VALUE for a SUBMIT INPUT in the
first place, really...



I think we all realize that. The point of the exercise was to 
understand what was happening.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-03 Thread tedd

At 3:28 PM -0600 1/3/08, Richard Lynch wrote:

On Wed, January 2, 2008 5:26 pm, tedd wrote:

 At 2:34 PM -0800 1/2/08, Jim Lucas wrote:

This I think shows what tedd is looking for.

so, from this I deduce that this should work.

$submit = trim($submit, \xA0\x20);

What do you guys/gals think?


 Nope, not a winner. But it produces some interesting results.


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



That's neat.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-03 Thread tedd

At 3:33 PM -0600 1/3/08, Richard Lynch wrote:

On Thu, January 3, 2008 11:39 am, tedd wrote:
  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.


Perhaps you should be taking a whitelist approach to filtering input?...


Yes, I always scrub and/or filter any data coming from the user-side.

This was just an experiment because the results I saw didn't fit what 
I (and appears others) expected.


Thanks for your input and code.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Nathan Nobbe
On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:

 Hi gang:

 I have a

 $submit = $_POST['submit'];

 The string contains:

 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

 (it's there to make a submit button wider)

 How can I strip out the nbsp; from the $submit string leaving A?

 I've tried

trim($submit);

 but, that don't work.

 Neither does:

$submit = str_replace('nbsp;','',$submit);

 or this:

$submit = str_replace(' ';','',$submit);

 I should know what to do, but in this case I don't.

 Help is always appreciated.


why dont you just style the button w/ css?

style=width:200px

-nathan


Re: [PHP] First stupid post of the year.

2008-01-02 Thread David Giragosian
On 1/2/08, Nathan Nobbe [EMAIL PROTECTED] wrote:

 On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:

  Hi gang:
 
  I have a
 
  $submit = $_POST['submit'];
 
  The string contains:
 
  nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 
  (it's there to make a submit button wider)
 
  How can I strip out the nbsp; from the $submit string leaving A?
 
  I've tried
 
 trim($submit);
 
  but, that don't work.
 
  Neither does:
 
 $submit = str_replace('nbsp;','',$submit);
 
  or this:
 
 $submit = str_replace(' ';','',$submit);
 
  I should know what to do, but in this case I don't.
 
  Help is always appreciated.


 why dont you just style the button w/ css?

 style=width:200px

 -nathan


Parse the string character by character discarding '' , 'n' , 'b' , 's'
, 'p' , and  ';'. Assuming of course that the part of the label you want to
keep is none of those characters.

-David


Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 1:46 PM -0500 1/2/08, Nathan Nobbe wrote:
On Jan 2, 2008 1:34 PM, tedd 
mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote:



nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

(it's there to make a submit button wider)


why dont you just style the button w/ css?

style=width:200px

-nathan



-nathan:

Have you tried that?

I have, and it don't work.

I can create wider buttonwhatever/button but I cannot create a 
wider input type=submit value=A submit button.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] First stupid post of the year.

2008-01-02 Thread Warren Vail
I often identify each of my submit buttons with different names and identify
which one was pressed by;

If(isset($_POST[submit1]))

Only one will ever be pressed at a time, and that allows me to use the same
page with multiple languages (substituting different values for different
languages).  As you can see I can ignore the value, and submit buttons are
not sent in the form if they are not clicked.

Another option,

Warren Vail

 -Original Message-
 From: Nathan Nobbe [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, January 02, 2008 10:46 AM
 To: tedd
 Cc: PHP General list
 Subject: Re: [PHP] First stupid post of the year.
 
 On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:
 
  Hi gang:
 
  I have a
 
  $submit = $_POST['submit'];
 
  The string contains:
 
  nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 
  (it's there to make a submit button wider)
 
  How can I strip out the nbsp; from the $submit string leaving A?
 
  I've tried
 
 trim($submit);
 
  but, that don't work.
 
  Neither does:
 
 $submit = str_replace('nbsp;','',$submit);
 
  or this:
 
 $submit = str_replace(' ';','',$submit);
 
  I should know what to do, but in this case I don't.
 
  Help is always appreciated.
 
 
 why dont you just style the button w/ css?
 
 style=width:200px
 
 -nathan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Daniel Brown
On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:
 Hi gang:

 I have a

 $submit = $_POST['submit'];

 The string contains:

 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

 (it's there to make a submit button wider)

 How can I strip out the nbsp; from the $submit string leaving A?

 I've tried

 trim($submit);

 but, that don't work.

 Neither does:

 $submit = str_replace('nbsp;','',$submit);

 or this:

 $submit = str_replace(' ';','',$submit);

 I should know what to do, but in this case I don't.

 Help is always appreciated.

?
// Your existing code here
$submit = trim(str_replace('nbsp;','',$submit);
?

-- 
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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Nathan Nobbe
On Jan 2, 2008 1:55 PM, tedd [EMAIL PROTECTED] wrote:

 At 1:46 PM -0500 1/2/08, Nathan Nobbe wrote:
 On Jan 2, 2008 1:34 PM, tedd
 mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote:
 
 
 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 
 (it's there to make a submit button wider)
 
 
 why dont you just style the button w/ css?
 
 style=width:200px
 
 -nathan


 -nathan:

 Have you tried that?

 I have, and it don't work.

 I can create wider buttonwhatever/button but I cannot create a
 wider input type=submit value=A submit button.


it appears to work for me  using firefox:

html
head
title
/title
/head
body
form
input type=submit style=width:250px value=Submit
form
/body
/html

-nathan


Re: [PHP] First stupid post of the year.

2008-01-02 Thread Daniel Brown
On Jan 2, 2008 1:55 PM, tedd [EMAIL PROTECTED] wrote:
 At 1:46 PM -0500 1/2/08, Nathan Nobbe wrote:
 On Jan 2, 2008 1:34 PM, tedd
 mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote:
 
 
 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 
 (it's there to make a submit button wider)
 
 
 why dont you just style the button w/ css?
 
 style=width:200px
 
 -nathan


 -nathan:

 Have you tried that?

 I have, and it don't work.

 I can create wider buttonwhatever/button but I cannot create a
 wider input type=submit value=A submit button.

Try this:

input type=submit value=A
style=width:160px;align:center;text-align:center;


-- 
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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Afan Pasalic

tedd wrote:

At 1:46 PM -0500 1/2/08, Nathan Nobbe wrote:
On Jan 2, 2008 1:34 PM, tedd 
mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote:



nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

(it's there to make a submit button wider)


why dont you just style the button w/ css?

style=width:200px

-nathan



-nathan:

Have you tried that?

I have, and it don't work.

I can create wider buttonwhatever/button but I cannot create a wider 
input type=submit value=A submit button.


Cheers,

tedd



Yes you can:
input type=submit value=A style=width: 25px; height: 10px;

-afan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Scott Wilcox

Add it inline, and it'll override everything else.

input type=submit style=width: 200px; name=bob /

tedd wrote:

At 1:46 PM -0500 1/2/08, Nathan Nobbe wrote:
On Jan 2, 2008 1:34 PM, tedd 
mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote:



nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

(it's there to make a submit button wider)


why dont you just style the button w/ css?

style=width:200px

-nathan



-nathan:

Have you tried that?

I have, and it don't work.

I can create wider buttonwhatever/button but I cannot create a 
wider input type=submit value=A submit button.


Cheers,

tedd



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 1:57 PM -0500 1/2/08, Daniel Brown wrote:

On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:


from this:

nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

to this A


?
// Your existing code here
$submit = trim(str_replace('nbsp;','',$submit);
?


Even with adding an additional ), that didn't work either.  :-)

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Jim Lucas
Nathan Nobbe wrote:
 On Jan 2, 2008 1:55 PM, tedd [EMAIL PROTECTED] wrote:
 
 At 1:46 PM -0500 1/2/08, Nathan Nobbe wrote:
 On Jan 2, 2008 1:34 PM, tedd
 mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote:


 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

 (it's there to make a submit button wider)


 why dont you just style the button w/ css?

 style=width:200px

 -nathan

 -nathan:

 Have you tried that?

 I have, and it don't work.

 I can create wider buttonwhatever/button but I cannot create a
 wider input type=submit value=A submit button.
 
 
 it appears to work for me  using firefox:
 
 html
 head
 title
 /title
 /head
 body
 form
 input type=submit style=width:250px value=Submit
 form
 /body
 /html
 
 -nathan
 

I prefer this approach instead.

html
head
title/title
style
button,
input[type=submit],
input[type=reset],
input[type=button] {
width:  250px;
}
/style
/head
body
form
input type=submit value=Submit
form
/body
/html


This way, you hit all your buttons with one style tag.

-- 
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Nathan Nobbe
i wonder what the record will be this year for the number of identical
responses
to a question in a single thread ;)
looks like this one is already out in front!

-nathan


Re: [PHP] First stupid post of the year.

2008-01-02 Thread Daniel Brown
On Jan 2, 2008 2:05 PM, tedd [EMAIL PROTECTED] wrote:
 At 1:57 PM -0500 1/2/08, Daniel Brown wrote:
 On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:

 from this:

 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

 to this A

 ?
 // Your existing code here
 $submit = trim(str_replace('nbsp;','',$submit);
 ?

 Even with adding an additional ), that didn't work either.  :-)


That was a typo on my part, but check it out here and you'll see
it works (you can view full source there, too):

http://pilotpig.net/code-library/tedds-button.php


-- 
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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] First stupid post of the year.

2008-01-02 Thread Bastien Koert

if you need to make the button wider, just style it with css and leave the 
value to be what it needs to be
 
input type='text' width='100px' value='Submit' name='submit' Date: Wed, 2 
Jan 2008 13:34:43 -0500 To: php-general@lists.php.net From: [EMAIL 
PROTECTED] Subject: [PHP] First stupid post of the year.  Hi gang:  I have 
a  $submit = $_POST['submit'];  The string contains:  nbsp; nbsp; 
nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;  (it's there to make a submit 
button wider)  How can I strip out the nbsp; from the $submit string 
leaving A?  I've tried  trim($submit);  but, that don't work.  
Neither does:  $submit = str_replace('nbsp;','',$submit);  or this:  
$submit = str_replace(' ';','',$submit);  I should know what to do, but in 
this case I don't.  Help is always appreciated.  Cheers,  tedd  --  
--- http://sperling.com http://ancientstones.com http://earthstones.com  
--  PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
http://www.php.net/unsub.php 
_
Use fowl language with Chicktionary. Click here to start playing!
http://puzzles.sympatico.msn.ca/chicktionary/index.html?icid=htmlsig

Re: [PHP] First stupid post of the year.

2008-01-02 Thread Nathan Nobbe
On Jan 2, 2008 2:05 PM, tedd [EMAIL PROTECTED] wrote:

 At 1:57 PM -0500 1/2/08, Daniel Brown wrote:
 On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:

 from this:

 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

 to this A

 ?
 // Your existing code here
 $submit = trim(str_replace('nbsp;','',$submit);
 ?

 Even with adding an additional ), that didn't work either.  :-)


first off; i think css is the way to go w/ this; to save yourself from these
headaches.  anyway; if you want to go this route, i think there is some info
we are missing.  im guessing you dont have the
nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
in the submit button itself, or do you?
i certainly dont know what the point of that would be since users wont
change
the value attribute of a submit button anyway.  so can we see the html for
the input
that contains the
nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

or maybe this is the first stupid response of the year!

-nathan


Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

Hi gang:

My apologies to all who responded with a css solution -- css DOES indeed work!.

I went from using button tags, which could be styled, but IE had 
problems with them -- to using submit buttons that IE could use, but 
my css no longer worked.


The reason why my css no longer worked was I used:

button {width:5em;}

instead of:

.button {width:5em;}

A little id v class problem.

BUT, while I don't need the solution any longer to strip out nbsp; 
from a string, the question still remains -- how do you do that?


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Daniel Brown
On Jan 2, 2008 2:10 PM, Jim Lucas [EMAIL PROTECTED] wrote:
 I prefer this approach instead.

 html
 head
 title/title
 style
 button,
 input[type=submit],
 input[type=reset],
 input[type=button] {
 width:  250px;
 }
 /style
 /head
 body
 form
 input type=submit value=Submit
 form
 /body
 /html

The problem is that it will force that style on all buttons where
that CSS is present.  With Tedd's particular request, I don't think he
needs (or especially wants) that portability.  This would be one of
the only instances, though, where Jim's response may not be the best.
In most other cases, that would be the most economic way.

-- 
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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Jim Lucas
Nathan Nobbe wrote:
 i wonder what the record will be this year for the number of identical
 responses
 to a question in a single thread ;)
 looks like this one is already out in front!
 
 -nathan
 

problem is, most of the responses have not answered the OP's inital question.

It wasn't about style it wider, it was about removing characters from a string.

-- 
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Jim Lucas
tedd wrote:
 Hi gang:
 
 I have a
 
 $submit = $_POST['submit'];
 
 The string contains:
 
 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 
 (it's there to make a submit button wider)
 
 How can I strip out the nbsp; from the $submit string leaving A?
 
 I've tried
 
trim($submit);
 
 but, that don't work.
 
 Neither does:
 
$submit = str_replace('nbsp;','',$submit);
 
 or this:
 
$submit = str_replace(' ';','',$submit);
 
 I should know what to do, but in this case I don't.
 
 Help is always appreciated.
 
 Cheers,
 
 tedd
 

The problem is, is that you are not getting

nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
when you submit your form.

It is being URL encoded by the browser and you are actually getting

amp;nbsp;%20amp;nbsp;%20amp;nbsp;%20amp;nbsp;Aamp;nbsp;%20amp;nbsp;%20amp;nbsp;%20amp;nbsp;

So, what you need to do is this

$submit = urldecode($submit);// This will take care of the %20 for spaces
$submit = str_replace('amp;nbsp;','',$submit); // This takes out the encoded 
entities

That should take care of your problem.

Here is a note from teh html_entity_decode page:

Note: You might wonder why trim(html_entity_decode('nbsp;')); doesn't reduce 
the string to an empty
string, that's because the 'nbsp;' entity is not ASCII code 32 (which is 
stripped by trim()) but
ASCII code 160 (0xa0) in the default ISO 8859-1 characterset.

/note

So, you might try replacing the nbsp; with ASCII 160 char.  I found that if 
you hold down the alt
key and press 160 on your keyboard, it will create that char for you.  you 
could also do a chr(160)
and get it in PHP.



-- 
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Jack Mays

tedd wrote:

Hi gang:

I have a

$submit = $_POST['submit'];

The string contains:

nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

(it's there to make a submit button wider)

How can I strip out the nbsp; from the $submit string leaving A?

I've tried

   trim($submit);

but, that don't work.

Neither does:

   $submit = str_replace('nbsp;','',$submit);

or this:

   $submit = str_replace(' ';','',$submit);

I should know what to do, but in this case I don't.

Help is always appreciated.



Just so we have all the info, why are you wanting to do this?  Why not 
just have the button text be what you want it instead of trying to do 
manipulation on it's value?


--
Jack Mays

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 2:18 PM -0500 1/2/08, Daniel Brown wrote:

On Jan 2, 2008 2:05 PM, tedd [EMAIL PROTECTED] wrote:

 At 1:57 PM -0500 1/2/08, Daniel Brown wrote:
 On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:

 from this:

 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

 to this A

 ?
 // Your existing code here

  $submit = trim(str_replace('nbsp;','',$submit);

 ?

 Even with adding an additional ), that didn't work either.  :-)



That was a typo on my part, but check it out here and you'll see
it works (you can view full source there, too):

http://pilotpig.net/code-library/tedds-button.php



If you look , you will see that your:

$submit = trim(str_replace('nbsp;','',$submit);

does not strip out the nbsp; from the string. B remains with spaces 
on either side -- at least on my browser.


However, the css style A button works great.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread afan pasalic
Daniel Brown wrote:
 On Jan 2, 2008 2:05 PM, tedd [EMAIL PROTECTED] wrote:
 At 1:57 PM -0500 1/2/08, Daniel Brown wrote:
 On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:
 from this:

 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

 to this A

 ?
 // Your existing code here
 $submit = trim(str_replace('nbsp;','',$submit);
 ?
 Even with adding an additional ), that didn't work either.  :-)
 
 
 That was a typo on my part, but check it out here and you'll see
 it works (you can view full source there, too):
 
 http://pilotpig.net/code-library/tedds-button.php
 


Since you don't use nbsp; any more
input type=submit name=submit value=A
style=width:160px;align:center;text-align:center; /
you don't need
$submit = trim(str_replace('nbsp;','',$submit));
right?

Also (fine tuning :)), I think you don't need whole
 ... style=width:160px;align:center;text-align:center; /
Just  ... style=width:160px; / because it's form button and it's by
default already centered.

-afan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Jack Mays

Daniel Brown wrote:

On Jan 2, 2008 2:05 PM, tedd [EMAIL PROTECTED] wrote:

At 1:57 PM -0500 1/2/08, Daniel Brown wrote:

On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:

from this:

nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

to this A


?
// Your existing code here
$submit = trim(str_replace('nbsp;','',$submit);


Read the docs for trim, you can't use it inline with other functions, it 
will not trim the input.  you have to seperate it out, e.g.:


 $submit = str_replace('nbsp;','',$submit);
 $submit = trim($submit);



?

Even with adding an additional ), that didn't work either.  :-)



That was a typo on my part, but check it out here and you'll see
it works (you can view full source there, too):

http://pilotpig.net/code-library/tedds-button.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Dave Goodchild
don't use nonbreaking spaces use CSS to style the input button then
you wont have to deal with redundant presentational gunk in your data

On 1/2/08, David Giragosian [EMAIL PROTECTED] wrote:
 On 1/2/08, Nathan Nobbe [EMAIL PROTECTED] wrote:
 
  On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:
 
   Hi gang:
  
   I have a
  
   $submit = $_POST['submit'];
  
   The string contains:
  
   nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
  
   (it's there to make a submit button wider)
  
   How can I strip out the nbsp; from the $submit string leaving A?
  
   I've tried
  
  trim($submit);
  
   but, that don't work.
  
   Neither does:
  
  $submit = str_replace('nbsp;','',$submit);
  
   or this:
  
  $submit = str_replace(' ';','',$submit);
  
   I should know what to do, but in this case I don't.
  
   Help is always appreciated.
 
 
  why dont you just style the button w/ css?
 
  style=width:200px
 
  -nathan
 

 Parse the string character by character discarding '' , 'n' , 'b' , 's'
 , 'p' , and  ';'. Assuming of course that the part of the label you want to
 keep is none of those characters.

 -David


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Nathan Nobbe
On Jan 2, 2008 2:27 PM, Jim Lucas [EMAIL PROTECTED] wrote:

 Nathan Nobbe wrote:
  i wonder what the record will be this year for the number of identical
  responses
  to a question in a single thread ;)
  looks like this one is already out in front!
 
  -nathan
 

 problem is, most of the responses have not answered the OP's inital
 question.

 It wasn't about style it wider, it was about removing characters from a
 string.


sometimes you have to realize the current solution may not be the best.
if you realize this issue could be dealt w/  by using css then all the
string filtering
nonsense becomes irrelevant.

and yes several people posted nearly identical solutions.

i know its futile to complain, sort of like the [SOLVED] thing we discussed
a while back.
well i just find it annoying when people dont bother to read through the
currently posted
solutions before posting the exact same thing or nearly identical thing
themselves.
if i were to post something nearly identical to a previously posted
solution, i would
preface it with an explanation, here is why, although a similar solution was
posted,
this subsequent post is relevant
anyway thats my little rant and now that ive said it; now ill go on ignoring
it..

-nathan


Re: [PHP] First stupid post of the year.

2008-01-02 Thread Daniel Brown
On Jan 2, 2008 1:26 PM, afan pasalic [EMAIL PROTECTED] wrote:
 Since you don't use nbsp; any more
 input type=submit name=submit value=A
 style=width:160px;align:center;text-align:center; /
 you don't need
 $submit = trim(str_replace('nbsp;','',$submit));
 right?

Negative.  That was to show how Form B is handled.

 Also (fine tuning :)), I think you don't need whole
  ... style=width:160px;align:center;text-align:center; /
 Just  ... style=width:160px; / because it's form button and it's by
 default already centered.

You're right about that part, I just typed it by force of habit.

-- 
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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 11:27 AM -0800 1/2/08, Jim Lucas wrote:

The problem is, is that you are not getting


Apparently, that makes two of us.  :-)


nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
when you submit your form.

It is being URL encoded by the browser and you are actually getting

amp;nbsp;%20amp;nbsp;%20amp;nbsp;%20amp;nbsp;Aamp;nbsp;%20amp;nbsp;%20amp;nbsp;%20amp;nbsp;

So, what you need to do is this

$submit = urldecode($submit);// This will take care of the %20 for spaces
$submit = str_replace('amp;nbsp;','',$submit); // This takes out 
the encoded entities


That should take care of your problem.


Good idea, but it still don't work -- try it.

Thanks.

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 2:22 PM -0500 1/2/08, Nathan Nobbe wrote:

first off; i think css is the way to go w/ this;
-snip


No, you are absolutely correct. The problem was that I was in a rush 
and forgot that I had used a class but had defined an id in my css.



or maybe this is the first stupid response of the year!

-nathan



Not at all -- your post forced me to try the concept in-line and when 
I saw it worked, then I went back to my css sheet to find out why it 
didn't before.


Just one of those things.

However, I still have not been able to remove nbsp; from a string.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Richard Lynch
echo trim(str_replace('nbsp;', '', $submit);

On Wed, January 2, 2008 12:34 pm, tedd wrote:
 Hi gang:

 I have a

 $submit = $_POST['submit'];

 The string contains:

 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

 (it's there to make a submit button wider)

 How can I strip out the nbsp; from the $submit string leaving A?

 I've tried

 trim($submit);

 but, that don't work.

 Neither does:

 $submit = str_replace('nbsp;','',$submit);

 or this:

 $submit = str_replace(' ';','',$submit);

 I should know what to do, but in this case I don't.

 Help is always appreciated.

 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Richard Lynch
On Wed, January 2, 2008 1:27 pm, Jim Lucas wrote:
 The string contains:

 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

 The problem is, is that you are not getting

 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 when you submit your form.

 It is being URL encoded by the browser and you are actually getting

 amp;nbsp;%20amp;nbsp;%20amp;nbsp;%20amp;nbsp;Aamp;nbsp;%20amp;nbsp;%20amp;nbsp;%20amp;nbsp;

But that is URL *DE*-coded by PHP internally before it's crammed into
$_POST/$_GET/$_COOKIES!

-- 
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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 11:27 AM -0800 1/2/08, Jim Lucas wrote:
Note: You might wonder why trim(html_entity_decode('nbsp;')); 
doesn't reduce the string to an empty
string, that's because the 'nbsp;' entity is not ASCII code 32 
(which is stripped by trim()) but

ASCII code 160 (0xa0) in the default ISO 8859-1 characterset.


Ah, that answers a question I posed last week about a gremlin 
appearing in a string. In a text file,via a Hex Editor it was 0A, but 
on the server it was 160 with some other character. Now, it makes 
sense.


Thanks,

ted
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Richard Lynch
On Wed, January 2, 2008 1:25 pm, Jack Mays wrote:
 Daniel Brown wrote:
 // Your existing code here
 $submit = trim(str_replace('nbsp;','',$submit);

 Read the docs for trim, you can't use it inline with other functions,

Please point to the specific portion of the docs in which you imagine
this to be written...

:-)

And, technically, if you are CERTAIN the button value will never ever
contain any of the characters '', 'n', 'b', 's', ';' then you could
use the new second arg of trim to do:

$submit = trim($_POST['submit'],  nbsp;\r\n\t\x0b\0);

and get rid of all whitespace and the 'nbsp;' as well...

Probably NOT a Good Idea in general, however...

-- 
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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 1:29 PM -0600 1/2/08, Jack Mays wrote:
Just so we have all the info, why are you wanting to do this?  Why 
not just have the button text be what you want it instead of trying 
to do manipulation on it's value?


Why?

It was just a mistaken assumption that I could not style a submit 
button and instead used nbsp;'s to make the button wider. After 
which, I would simply remove the spaces before submitting them to a 
switch/case condition.


There is nothing wrong with my logic, it was an error in my css.

People use submit buttons lot's of different ways and there is no one 
correct way. But, as far as I am concerned, the value of a submit 
button is what I'm after, so doing something like this:


input  type=submit class=button name=submit value=A
input  type=submit class=button name=submit value=B
...

followed by:

$submit = $_POST['submit'];

switch $submit
  {
  case 'A':
  do something;
  break;

  case 'B':
  do something else;
  break;
   ...
   }

is a good way to handle user input. I see no fault in logic.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 11:10 AM -0800 1/2/08, Jim Lucas wrote:



I prefer this approach instead.

html
head
title/title
style
button,
input[type=submit],
input[type=reset],
input[type=button] {
width:  250px;
}
/style
/head
body
form
input type=submit value=Submit
form
/body
/html


I prefer this:

in css

.button
   {
   width: 5em;
   }

in html

input  type=submit class=button name=submit valueA

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 1:25 PM -0600 1/2/08, Jack Mays wrote:



On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:

from this:

nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

to this A


Read the docs for trim, you can't use it inline with other 
functions, it will not trim the input.  you have to seperate it out, 
e.g.:


 $submit = str_replace('nbsp;','',$submit);
 $submit = trim($submit);


But, that still doesn't work.

Go from here:

nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

to here:

A

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 7:36 PM + 1/2/08, Dave Goodchild wrote:

don't use nonbreaking spaces use CSS to style the input button then
you wont have to deal with redundant presentational gunk in your data


OK!

But, do you have a solution to the original question?

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Wolf

 tedd [EMAIL PROTECTED] wrote: 
 Hi gang:
 
 I have a
 
 $submit = $_POST['submit'];
 
 The string contains:
 
 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 
 (it's there to make a submit button wider)
 
 How can I strip out the nbsp; from the $submit string leaving A?
 
 I've tried
 
 trim($submit);
 
 but, that don't work.
 
 Neither does:
 
 $submit = str_replace('nbsp;','',$submit);
 
 or this:
 
 $submit = str_replace(' ';','',$submit);
 
 I should know what to do, but in this case I don't.
 
 Help is always appreciated.
 
 Cheers,
 
 tedd
 
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
input type=text value=A size=50
input type=submit

Wolf

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 2:36 PM -0500 1/2/08, Nathan Nobbe wrote:

and yes several people posted nearly identical solutions.

i know its futile to complain, sort of like the [SOLVED] thing we discussed
a while back.
well i just find it annoying when people dont bother to read through the
currently posted
solutions before posting the exact same thing or nearly identical thing
themselves.



Yeah, but what's the fun in doing it that way?

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Janet Valade

tedd wrote:



However, I still have not been able to remove nbsp; from a string.


IThe trim(str_replace('nbsp;','',$submit)); seems to work fine for me 
when I assign the string from your message to $submit. Copy/pasted it. 
Have you looked at $submit with var_dump before you tried to change it? 
Perhaps it does not contain what you think it does.


Janet



Cheers,

tedd



--

janet.valade.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Wolf

 tedd [EMAIL PROTECTED] wrote: 
 At 1:25 PM -0600 1/2/08, Jack Mays wrote:
 
 On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:
 from this:
 
 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 
 to this A
 
 Read the docs for trim, you can't use it inline with other 
 functions, it will not trim the input.  you have to seperate it out, 
 e.g.:
 
   $submit = str_replace('nbsp;','',$submit);
   $submit = trim($submit);
 
 But, that still doesn't work.
 
 Go from here:
 
 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 
 to here:
 
 A
 
 Cheers,
 
 tedd
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
$string=nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;;
$string=str_replace(nbsp;,,$string);
$string=ltrim(rtrim($string)));
echo The string is now:$string\n;

Outputs:
The string is now:A

Wolf

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Robert Cummings
?php

$foo = 'nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;';
$foo = str_replace( 'nbsp;', ' ', $foo );
$foo = trim( ereg_replace( '[ ]+', ' ', $foo ) );

echo '['.$foo.']'.\n;

?

I could have replaced 'nbsp;' with the empty string, but in case you
have labels with more than one word I took a normalizing approach.

Cheers,
Rob.


On Wed, 2008-01-02 at 13:34 -0500, tedd wrote:
 Hi gang:
 
 I have a
 
 $submit = $_POST['submit'];
 
 The string contains:
 
 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 
 (it's there to make a submit button wider)
 
 How can I strip out the nbsp; from the $submit string leaving A?
 
 I've tried
 
 trim($submit);
 
 but, that don't work.
 
 Neither does:
 
 $submit = str_replace('nbsp;','',$submit);
 
 or this:
 
 $submit = str_replace(' ';','',$submit);
 
 I should know what to do, but in this case I don't.
 
 Help is always appreciated.
 
 Cheers,
 
 tedd
 
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Casey
On Jan 2, 2008 12:11 PM, tedd [EMAIL PROTECTED] wrote:
 At 2:36 PM -0500 1/2/08, Nathan Nobbe wrote:
 and yes several people posted nearly identical solutions.
 
 i know its futile to complain, sort of like the [SOLVED] thing we discussed
 a while back.
 well i just find it annoying when people dont bother to read through the
 currently posted
 solutions before posting the exact same thing or nearly identical thing
 themselves.


 Yeah, but what's the fun in doing it that way?

 Cheers,

 tedd



$value = trim($value, chr(32) . chr(160));
Cookie for me? :)
-- 
-Casey

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Daniel Brown
On Jan 2, 2008 3:16 PM, Wolf [EMAIL PROTECTED] wrote:
[snip=all]

Okay, first of all, Tedd's right my thing didn't work, because
I had copied over a script I was working with on the CLI.

Secondly, the trim() and str_replace() things work great from the
CLI, but not when transmogrified by a combination of the browser, HTTP
server, and PHP.  Thus, the non-elegant solution that Really Works[tm]
is now properly displayed:

http://www.pilotpig.net/code-library/tedds-button.php

It's ugly, but it does the job.  Kinda' like its programmer.


-- 
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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Richard Lynch
On Wed, January 2, 2008 2:09 pm, tedd wrote:
 At 1:25 PM -0600 1/2/08, Jack Mays wrote:

On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:
from this:

nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

to this A

Read the docs for trim, you can't use it inline with other
functions, it will not trim the input.  you have to seperate it out,
e.g.:

  $submit = str_replace('nbsp;','',$submit);
  $submit = trim($submit);

 But, that still doesn't work.

 Go from here:

 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

 to here:

 A

Works for me:

[EMAIL PROTECTED] ~/cd $ php -a
Interactive mode enabled

?php
$a = 'nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;';
$b = str_replace('nbsp;', '', $a);
echo b: $b\n\n;
$c = trim($b);
echo c: $c\n\n;
?
b:A

c: A


[EMAIL PROTECTED] ~/cd $

-- 
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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Daniel Brown
On Jan 2, 2008 3:58 PM, Richard Lynch [EMAIL PROTECTED] wrote:
 Works for me:

 [EMAIL PROTECTED] ~/cd $ php -a
 Interactive mode enabled

 ?php
 $a = 'nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;';
 $b = str_replace('nbsp;', '', $a);
 echo b: $b\n\n;
 $c = trim($b);
 echo c: $c\n\n;
 ?
 b:A

 c: A

Tedd's problem is that it's not working on the web, though, Rich.
I tested mine and it worked fine from the CLI, too, but not when
encoded and then decoded via HTTP.

-- 
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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Casey
On Jan 2, 2008 12:58 PM, Richard Lynch [EMAIL PROTECTED] wrote:
 On Wed, January 2, 2008 2:09 pm, tedd wrote:
  At 1:25 PM -0600 1/2/08, Jack Mays wrote:
 
 On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote:
 from this:
 
 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 
 to this A
 
 Read the docs for trim, you can't use it inline with other
 functions, it will not trim the input.  you have to seperate it out,
 e.g.:
 
   $submit = str_replace('nbsp;','',$submit);
   $submit = trim($submit);
 
  But, that still doesn't work.
 
  Go from here:
 
  nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 
  to here:
 
  A

 Works for me:

 [EMAIL PROTECTED] ~/cd $ php -a
 Interactive mode enabled

 ?php
 $a = 'nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;';
 $b = str_replace('nbsp;', '', $a);
 echo b: $b\n\n;
 $c = trim($b);
 echo c: $c\n\n;
 ?
 b:A

 c: A


 [EMAIL PROTECTED] ~/cd $

 --
 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?

 --

 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


OKAY. Let's clarify.

Here's the string in HTML:
nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

The browser then passes it to GET/POST. It decodes the entities, and
then urlencodes them. Now it looks like this:
%a0%20%a0%20%a0%20%a0A%a0%20%a0%20%a0%20%a0

Then PHP receives it, urldecodes the string, then stuffs it inside
$_POST, $_GET, $_REQUEST, etc. Now it's like this:
   A

$_POST['submit'] == '   A   ' // TRUE.


... *pokes my solution*...
$value = trim($value, chr(32) . chr(160));
-- 
-Casey

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Daniel Brown
On Jan 2, 2008 4:08 PM, Casey [EMAIL PROTECTED] wrote:
 ... *pokes my solution*...
 $value = trim($value, chr(32) . chr(160));

You're solution is good, Casey we're just ignoring you because
you smell funny.

-- 
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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Robert Cummings
On Wed, 2008-01-02 at 16:15 -0500, Daniel Brown wrote:
 On Jan 2, 2008 4:08 PM, Casey [EMAIL PROTECTED] wrote:
  ... *pokes my solution*...
  $value = trim($value, chr(32) . chr(160));
 
 You're solution is good, Casey we're just ignoring you because
 you smell funny.

Is that what that is :|

I thought it was my daughter's diaper!

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Jim Lucas
Richard Lynch wrote:
 On Wed, January 2, 2008 1:27 pm, Jim Lucas wrote:
 The string contains:

 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

 The problem is, is that you are not getting

 nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;
 when you submit your form.

 It is being URL encoded by the browser and you are actually getting

 amp;nbsp;%20amp;nbsp;%20amp;nbsp;%20amp;nbsp;Aamp;nbsp;%20amp;nbsp;%20amp;nbsp;%20amp;nbsp;
 
 But that is URL *DE*-coded by PHP internally before it's crammed into
 $_POST/$_GET/$_COOKIES!
 

Ok, so here is my little friend, my packet exploder...

So, I wrote this packet decoder last week for a different project.  Come to 
find out, it is a very
hand little tool.

Takes text input and dumps it like a normal packet analyzer application.

Check out what is found.

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

This I think shows what tedd is looking for.

so, from this I deduce that this should work.

$submit = trim($submit, \xA0\x20);

What do you guys/gals think?

-- 
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 2:34 PM -0800 1/2/08, Jim Lucas wrote:

This I think shows what tedd is looking for.

so, from this I deduce that this should work.

$submit = trim($submit, \xA0\x20);

What do you guys/gals think?


Nope, not a winner. But it produces some interesting results.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 3:36 PM -0500 1/2/08, Daniel Brown wrote:

On Jan 2, 2008 3:16 PM, Wolf [EMAIL PROTECTED] wrote:
[snip=all]

Okay, first of all, Tedd's right my thing didn't work, because
I had copied over a script I was working with on the CLI.

Secondly, the trim() and str_replace() things work great from the
CLI, but not when transmogrified by a combination of the browser, HTTP
server, and PHP.  Thus, the non-elegant solution that Really Works[tm]
is now properly displayed:

http://www.pilotpig.net/code-library/tedds-button.php

It's ugly, but it does the job.  Kinda' like its programmer.


Nope, it produces:

%C2%C2%C2%C2%C2A%C2%C2%C2

Thanks for trying :-)

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 2:58 PM -0600 1/2/08, Richard Lynch wrote:

Works for me:

[EMAIL PROTECTED] ~/cd $ php -a
Interactive mode enabled

?php
$a = 'nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;';
$b = str_replace('nbsp;', '', $a);
echo b: $b\n\n;
$c = trim($b);
echo c: $c\n\n;
?
b:A

c: A


That would work for that, but not for this:

Go from this:

input type=submit value=nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp

via this:

$submit = $_POST['submit']

to:

A

It doesn't appear as simple as what people think it is.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 1:08 PM -0800 1/2/08, Casey wrote:


OKAY. Let's clarify.

Here's the string in HTML:
nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;

The browser then passes it to GET/POST. It decodes the entities, and
then urlencodes them. Now it looks like this:
%a0%20%a0%20%a0%20%a0A%a0%20%a0%20%a0%20%a0

Then PHP receives it, urldecodes the string, then stuffs it inside
$_POST, $_GET, $_REQUEST, etc. Now it's like this:
   A

$_POST['submit'] == '   A   ' // TRUE.


... *pokes my solution*...
$value = trim($value, chr(32) . chr(160));


Good clarification, but not a solution. It didn't work.

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 4:15 PM -0500 1/2/08, Daniel Brown wrote:

On Jan 2, 2008 4:08 PM, Casey [EMAIL PROTECTED] wrote:

 ... *pokes my solution*...
 $value = trim($value, chr(32) . chr(160));


You're solution is good, Casey we're just ignoring you because
you smell funny.


I'm not ignoring him -- it don't work.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 3:11 PM -0500 1/2/08, Wolf wrote:


  --

 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

input type=text value=A size=50
input type=submit

Wolf


Nice idea, but the submit button has to have the value of A.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 3:16 PM -0500 1/2/08, Wolf wrote:


  --

 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

$string=nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;;
$string=str_replace(nbsp;,,$string);
$string=ltrim(rtrim($string)));
echo The string is now:$string\n;

Outputs:
The string is now:A

Wolf


While that does, that's not the problem.

The problem is:

input type=submit value=nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp

via this:

$submit = $_POST['submit']

to produce:

A

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 3:20 PM -0500 1/2/08, Robert Cummings wrote:

?php

$foo = 'nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;';
$foo = str_replace( 'nbsp;', ' ', $foo );
$foo = trim( ereg_replace( '[ ]+', ' ', $foo ) );

echo '['.$foo.']'.\n;

?


Nope, still didn't work for going from this:

input type=submit value=nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp

to this:

A

via

$submit = $_POST['submit'];

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 12:27 PM -0800 1/2/08, Casey wrote:

$value = trim($value, chr(32) . chr(160));
Cookie for me? :)
--
-Casey



No cookie for you. It didn't work.

Cheers,

tedd



--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Daniel Brown
On Jan 2, 2008 6:32 PM, tedd [EMAIL PROTECTED] wrote:
 At 3:36 PM -0500 1/2/08, Daniel Brown wrote:
 On Jan 2, 2008 3:16 PM, Wolf [EMAIL PROTECTED] wrote:
 [snip=all]
 
  Okay, first of all, Tedd's right my thing didn't work, because
 I had copied over a script I was working with on the CLI.
 
  Secondly, the trim() and str_replace() things work great from the
 CLI, but not when transmogrified by a combination of the browser, HTTP
 server, and PHP.  Thus, the non-elegant solution that Really Works[tm]
 is now properly displayed:
 
  http://www.pilotpig.net/code-library/tedds-button.php
 
  It's ugly, but it does the job.  Kinda' like its programmer.

 Nope, it produces:

 %C2%C2%C2%C2%C2A%C2%C2%C2

 Thanks for trying :-)

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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread Jim Lucas
tedd wrote:
 At 2:34 PM -0800 1/2/08, Jim Lucas wrote:
 This I think shows what tedd is looking for.

 so, from this I deduce that this should work.

 $submit = trim($submit, \xA0\x20);

 What do you guys/gals think?
 
 Nope, not a winner. But it produces some interesting results.
 
 Cheers,
 
 tedd
 

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
  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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-02 Thread tedd

At 6:42 PM -0500 1/2/08, Daniel Brown wrote:

On Jan 2, 2008 6:32 PM, tedd [EMAIL PROTECTED] wrote:

  Nope, it produces:


 %C2%C2%C2%C2%C2A%C2%C2%C2

 Thanks for trying :-)


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


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 nbsp;


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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 4:34 PM -0800 1/2/08, Jim Lucas wrote:

tedd wrote:

 At 2:34 PM -0800 1/2/08, Jim Lucas wrote:

 This I think shows what tedd is looking for.

 so, from this I deduce that this should work.


  $submit = trim($submit, \xA0\x20);


 What do you guys/gals think?



  Nope, not a winner. But it produces some interesting results.
 
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
  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?


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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year. [SOLVED]

2008-01-02 Thread Daniel Brown
On Jan 2, 2008 7:36 PM, tedd [EMAIL PROTECTED] wrote:
 At 6:42 PM -0500 1/2/08, Daniel Brown wrote:
 On Jan 2, 2008 6:32 PM, tedd [EMAIL PROTECTED] wrote:
 
Nope, it produces:
 
   %C2%C2%C2%C2%C2A%C2%C2%C2
 
   Thanks for trying :-)
 
  Why is it that things work perfectly for me until you test them?

 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 nbsp;

 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.

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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] First stupid post of the year.

2008-01-02 Thread tedd

At 1:38 AM +0100 1/3/08, Jochem (mobile) wrote:

tedd schreef:

 At 3:11 PM -0500 1/2/08, Wolf wrote:


   --

  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php

 input type=text value=A size=50
 input type=submit

 Wolf


 Nice idea, but the submit button has to have the value of A.


well I don't think it does. you could try another approach,



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php