Re: [PHP] [NOT FIXED] Re: [PHP] strip out wierd characters in a string

2004-10-18 Thread Curt Zirzow
* Thus wrote Brent Clements:
> Ok, I still have the problem.
> 
> If I echo the string to a webpage, it still contains the ?
> 
> So I viewed the source in a notepad, and the thing that shows up next to
> "string" is a TM.
> 
> I tried using htmlentities on the string that I'm echoing but the question
> mark/tm is still there.
> 
> Anybody know how to fix this?

The ? you are seeing is because the charset doesn't know what to do
with the ascii value that is contained there.

You have a couple of options to let the browser know exactly what
you mean by that character:

If before any output you specify:

  header('Content-Type: text/html; charset=iso-8859-1');

will let the browser know you want a charset that defines
what that ascii value means

Or

Because there is no entity defined the htmlentities() for 'tm' you
have to convert it yourself using the numeric entity for it:

echo str_replace("\x99", "™", $a);


Then, your 'tm' will get displayed insted of '?'.


Curt
-- 
Quoth the Raven, "Nevermore."

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



Re: [PHP] [NOT FIXED] Re: [PHP] strip out wierd characters in a string

2004-10-18 Thread Brian
Note:  The below function will also strip out tabs and newline characters.

function str_clean($str) 
{
  for($i = 0; $i < strlen($str); $i++) 
{ 
$tmp=ord($str[$i]))
if ($tmp>31 && $tmp <127)
  {
  $new_str .= $str[$i];
  }
} 
  return($new_str); 
}


On Mon, 18 Oct 2004 01:51:22 -0500, Brent Clements
<[EMAIL PROTECTED]> wrote:
> Ok, I still have the problem.
> 
> If I echo the string to a webpage, it still contains the ?
> 
> So I viewed the source in a notepad, and the thing that shows up next to
> "string" is a TM.
> 
> I tried using htmlentities on the string that I'm echoing but the question
> mark/tm is still there.
> 
> Anybody know how to fix this?
> 
> 
> 
> -Brent
> - Original Message -
> From: "Brent Clements" <[EMAIL PROTECTED]>
> To: "Brent Clements" <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Monday, October 18, 2004 1:42 AM
> Subject: Re: [PHP] strip out wierd characters in a string
> 
> > Solved my own problem.
> >
> > I ran the script itself from the unix prompt and forced it's output to a
> > text file
> > I then viewed the text file and saw the actual wierd character. I then
> used
> > strtr to replace the wierd character with a single space.
> >
> > Pretty simple and clean way to fix this.
> >
> > -Brent
> >
> > - Original Message -
> > From: "Brent Clements" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, October 18, 2004 1:22 AM
> > Subject: [PHP] strip out wierd characters in a string
> >
> >
> > Hi Guys,
> >  I think that a string that I'm grabbing from a website was actually
> created
> > using ms-word. If I echo the string out, it has a question mark in it.
> >
> > If you look at the website, the text is fine
> > ie"string some more text"
> >
> > but when I grab it from the website, and then echo the string, I get.
> >
> > "string? some more text"
> >
> > I have tried doing this
> >
> > echo str_replace("?", " ", $text);
> >
> > but it still print's out the ?. I think it's because the string itself has
> a
> > wierd binary character in it or something.
> >
> > Anyone know how to fix this?
> >
> > Thanks,
> > Brent
> >
> >
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

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



[PHP] [NOT FIXED] Re: [PHP] strip out wierd characters in a string

2004-10-17 Thread Brent Clements
Ok, I still have the problem.

If I echo the string to a webpage, it still contains the ?

So I viewed the source in a notepad, and the thing that shows up next to
"string" is a TM.

I tried using htmlentities on the string that I'm echoing but the question
mark/tm is still there.

Anybody know how to fix this?

-Brent
- Original Message - 
From: "Brent Clements" <[EMAIL PROTECTED]>
To: "Brent Clements" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Monday, October 18, 2004 1:42 AM
Subject: Re: [PHP] strip out wierd characters in a string


> Solved my own problem.
>
> I ran the script itself from the unix prompt and forced it's output to a
> text file
> I then viewed the text file and saw the actual wierd character. I then
used
> strtr to replace the wierd character with a single space.
>
> Pretty simple and clean way to fix this.
>
> -Brent
>
> - Original Message - 
> From: "Brent Clements" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, October 18, 2004 1:22 AM
> Subject: [PHP] strip out wierd characters in a string
>
>
> Hi Guys,
>  I think that a string that I'm grabbing from a website was actually
created
> using ms-word. If I echo the string out, it has a question mark in it.
>
> If you look at the website, the text is fine
> ie"string some more text"
>
> but when I grab it from the website, and then echo the string, I get.
>
> "string? some more text"
>
> I have tried doing this
>
> echo str_replace("?", " ", $text);
>
> but it still print's out the ?. I think it's because the string itself has
a
> wierd binary character in it or something.
>
> Anyone know how to fix this?
>
> Thanks,
> Brent
>
>

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