Re: Displaying UTF-8-encoded strings from MySQL with PHP [message #174531 is a reply to message #174526] |
Thu, 16 June 2011 07:29 |
alvaro.NOSPAMTHANX
Messages: 277 Registered: September 2010
Karma:
|
Senior Member |
|
|
El 15/06/2011 18:07, Jerry Stuckle escribió/wrote:
>> With mb_convert_encoding() you can retrieve and store UTF-8 data even if
>> your app does not use it ;-)
>>
>>
>
> How's mb_convert_encoding() working? Is it correct in converting
> (assuming, of course, the character exists in the character set being
> converted to).
You can do something like this:
mb_convert_encoding(
htmlspecialchars($foo, ENT_COMPAT, 'UTF-8'),
'HTML-ENTITIES',
'UTF-8'
)
From "ABC <123> áéí € ㍝" you'd get:
ABC <123> áéí € ㍝
It's not something I'd recommend if you can avoid it but it can be done.
> I'm asking this because I only dabbled a bit in utf-8 several years ago,
> and haven't touched it since (yea, we Americans think the whole world
> revolves around us :) ). But I may soon be involved in a project which
> does use it.
Well, you Americans can switch to UTF-8 quite easily, given that's a
superset of good old 7-bit ASCII. It's not like in Europe, where failing
to recognise the file charset will ruin your data :)
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
|
|
|