Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #2201

Re: Displaying UTF-8-encoded strings from MySQL with PHP

From "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid>
Newsgroups comp.lang.php
Subject Re: Displaying UTF-8-encoded strings from MySQL with PHP
Date 2011-06-16 09:29 +0200
Organization http://alvaro.es/
Message-ID <itcbdj$5dp$1@dont-email.me> (permalink)
References <e1fa9d06-3720-4489-9667-14bba4aa3506@d1g2000yqm.googlegroups.com> <ita1dk$1b8$1@dont-email.me> <ita2uk$a3f$1@dont-email.me> <ita6mq$vtv$1@dont-email.me> <italc3$4n8$1@dont-email.me>

Show all headers | View raw


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
--

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Displaying UTF-8-encoded strings from MySQL with PHP Luke <kickingjesus@gmail.com> - 2011-06-15 03:18 -0700
  Re: Displaying UTF-8-encoded strings from MySQL with PHP "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-06-15 12:26 +0200
    Re: Displaying UTF-8-encoded strings from MySQL with PHP Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-15 06:53 -0400
      Re: Displaying UTF-8-encoded strings from MySQL with PHP "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-06-15 13:57 +0200
        Re: Displaying UTF-8-encoded strings from MySQL with PHP Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-15 12:07 -0400
          Re: Displaying UTF-8-encoded strings from MySQL with PHP "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-06-16 09:29 +0200
    Re: Displaying UTF-8-encoded strings from MySQL with PHP Luke <kickingjesus@gmail.com> - 2011-06-15 05:56 -0700
      Re: Displaying UTF-8-encoded strings from MySQL with PHP Luke <kickingjesus@gmail.com> - 2011-06-15 06:05 -0700
        Re: Displaying UTF-8-encoded strings from MySQL with PHP Luke <kickingjesus@gmail.com> - 2011-06-15 06:23 -0700
          Re: Displaying UTF-8-encoded strings from MySQL with PHP Luke <kickingjesus@gmail.com> - 2011-06-15 06:50 -0700
            Re: Displaying UTF-8-encoded strings from MySQL with PHP "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-06-15 16:17 +0200
              Re: Displaying UTF-8-encoded strings from MySQL with PHP Tim Streater <timstreater@waitrose.com> - 2011-06-15 15:26 +0100
  Re: Displaying UTF-8-encoded strings from MySQL with PHP Jo Schulze <antispam@feuersee.de> - 2011-06-16 23:34 +0200
    Re: Displaying UTF-8-encoded strings from MySQL with PHP "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-06-17 13:23 +0200

csiph-web