Re: strange character
| From: | Christoph Becker | Date: | Wed, 25 Feb 2015 23:33:53 +0000 |
| Subject: | Re: strange character | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324527@lists.php.net to get a copy of this message | ||
hadi wrote:
> Im trying to use (iconv("UTF-8", 'CP1256//TRANSLIT', $rss);) to convert
> strange character like (–) to proper character, but im getting error
>
> I googled about it but never found anything about it.
>
> Here is the error
>
> Notice: iconv(): Detected an illegal character in input string in
> /var/www/html/rssfeed/sahafah.php on line 35
Well, apparently these characters are invalid UTF-8 sequences, so trying
to convert them to another character encoding is likely to fail.
I'm not aware of a PHP function to strip invalid UTF-8 sequences that is
built-in to PHP or one of the common extensions, but there are userland
solutions available, for instance, utf8_bad_strip()[1].
[1]
<http://phputf8.cvs.sourceforge.net/viewvc/phputf8/utf8/utils/bad.php?view=markup&pathrev=MAIN>
--
Christoph M. Becker