Re: triming utf8 (?) a string
| From: | Jim Lucas | Date: | Mon, 09 Jul 2007 14:45:10 +0000 |
| Subject: | Re: triming utf8 (?) a string | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258499@lists.php.net to get a copy of this message | ||
Rick Pasotto wrote:
On Sun, Jul 08, 2007 at 06:30:54PM -0700, Jim Lucas wrote:Nope, not confused, but I ASSUMED that maybe the chars were not at the beginning or ending of the string, but somewhere in the middle. ( you didn't say where the chars were ) And since you were using trim(), that you were using the wrong function. Which only works on the beginning and ending of a string.Rick Pasotto wrote:But it *is* a single char that I'm wanting to remove (multiple times). Perhaps you are confusing a char with a byte?I'm using the PEAR Crypt_Blowfish module. When I decrypt the encrypted string the result is the original plus some '\ufffd' bytes. How can I get rid of those extra bytes? I've tried both trim($x,'\ufffd') and trim($x,utf8_decode('\ufffd')).trim() is meant to remove chars from the beginning and ending of a string. http://us2.php.net/str_replace is meant to remove a set of chars from a string. Anywhere within the string.
Anyway, the problem is solved from the other end. So long as the original string has a length that is a multiple of 8 the encoded/decoded result has no extra chars. Padding the initial string with spaces makes it easy to then trim() the output.-- 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