FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Displaying UTF-8-encoded strings from MySQL with PHP
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Displaying UTF-8-encoded strings from MySQL with PHP [message #174531 is a reply to message #174526] Thu, 16 June 2011 07:29 Go to previous messageGo to previous message
alvaro.NOSPAMTHANX is currently offline  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 &lt;123&gt; &aacute;&eacute;&iacute; &euro; &#13149;

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
--
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How do I force PHP to assume UTF-8 for $_GET?
Next Topic: radio button change after going to next page
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 21:35:24 GMT 2024

Total time taken to generate the page: 0.09406 seconds