Re: htmlspecialchars and UTF-8
| From: | Moriyoshi Koizumi | Date: | Wed, 04 Dec 2002 19:22:03 +0000 |
| Subject: | Re: htmlspecialchars and UTF-8 | ||
| References: | 1 | Groups: | php.i18n |
| Request: | Send a blank email to php-i18n+get-369@lists.php.net to get a copy of this message | ||
Hi,
If you want to do the full entity translation, use htmlentities() instead
of htmlspecialchars()
http://www.php.net/htmlspecialchars
Moriyoshi
"Renato De Giovanni" <renato@cria.org.br> wrote:
> Hi,
>
> We're working on a program that needs to generate an xml document, utf-8
> encoded, based on information stored with another charset encoding inside a
> database.
>
> So basically at some point we have a function that looks like:
>
> function encodeString($s, $encoding)
> {
> $s = mb_convert_encoding($s, 'UTF-8', $encoding);
>
> $s = htmlspecialchars($s, ENT_COMPAT, 'UTF-8');
>
> return $s;
> }
>
> What happens is that "htmlspecialchars" seems to be always returning a
> latin1 string, therefore causing problems with the generated document
> supposedly utf-8 encoded.
>
> My question is: is this a php bug or am I misunderstanding something related
> to multi-byte character support?
>
> PHP version is 4.2.3
>
> Thank you very much!
> --
> Renato
> CRIA - Centro de Referencia em Informacao Ambiental
> http://www.cria.org.br/
>
>
> --
> This message has been scanned for viruses and
> dangerous content and is believed to be clean.
>
>
> --
> PHP Internationalization Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>