RE: [PHP] RE: Re: high-bit characters

2007-06-09 Thread WeberSites LTD
Thanks, I'll have a look at it.

I do want to allow some chars so I'm trying to replace them 
like this : 

$post_text=str_replace(chr(146),',$post_text);

or

$post_text=str_replace(’,',$post_text);


However, it seems that str_replace does not actually replace
the chars cause they still end up in the output.

any idea?

berber

-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Abdullah Ramazanoglu
Sent: Saturday, June 09, 2007 3:21 PM
To: php-general@lists.php.net
Subject: [PHP] RE: Re: high-bit characters

WeberSites LTD dedi ki:

 Thanks, I'll check this out.
 
 Till now I managed to get the result I wanted with :
 
 ?php
 for ($i=0 ; $i  strlen($post_text) ; $i++) { $chr = $post_text{$i}; 
 $ord = ord($chr); if (($ord32 or $ord126) and ($ord != 13) and ($ord 
 != 10)){ Echo BAD CHAR is :  . $ord; break; } } ?

My suggestion finds high-bit characters (127-255), but you need to find
printable characters with the exception of \n and \r. So my suggestion won't
work for you, I'm afraid. Perhaps you want something like below?

$bad_string_flag = ! ctype_print(strtr($string, \n\r,   ));

From the docs, it seems that replacement string in strtr cannot be null for
correct operation, so I've used double blanks (or use any chars, e.g. NR).
The strtr part feels a bit clumsy, but you might be able to find a better
way in XVII. Character Type Functions or CLXI. String Functions (PHP
Manual).

Kind regards,
Abdullah

 
 
 berber
 
 -Original Message-
 From: news [mailto:[EMAIL PROTECTED] On Behalf Of Abdullah 
 Ramazanoglu
 Sent: Friday, June 08, 2007 11:43 PM
 To: php-general@lists.php.net
 Subject: [PHP] Re: high-bit characters
 
 WeberSites LTD dedi ki:
 
 I'm trying to validate an RSS feed and getting errors about high-bit 
 characters.
 How can I check if a string contains any high-bit characters?
 
 if (preg_match(/[\x80-\xff]/, $string)) {
 # high-bit char found
 } else {
 # no high-bit char
 }
 
 --
 Abdullah Ramazanoglu
 aramazan ÄT myrealbox D0T cöm
 
 --
 PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
 http://www.php.net/unsub.php
 

--
Abdullah Ramazanoglu
aramazan ÄT myrealbox D0T cöm

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



RE: [PHP] RE: Re: high-bit characters

2007-06-09 Thread Richard Lynch
On Sat, June 9, 2007 10:43 am, WeberSites LTD wrote:
 I do want to allow some chars so I'm trying to replace them
 like this :

 $post_text=str_replace(chr(146),',$post_text);

 or

 $post_text=str_replace(’,',$post_text);


 However, it seems that str_replace does not actually replace
 the chars cause they still end up in the output.

I dunno...

It's worked for me to rip out stupid Microsoft characters for years
and years now...

Paste actual source code, please.

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