PHP Developers Network
http://forums.devnetwork.net/

Using mb_convert_encoding() to convert UTF8 to UTF8
http://forums.devnetwork.net/viewtopic.php?f=34&t=134899
Page 1 of 1

Author:  Christopher [ Fri Mar 16, 2012 12:34 am ]
Post subject:  Using mb_convert_encoding() to convert UTF8 to UTF8

Should you use mb_convert_encoding() like you show for any character encoding you are using -- or only UTF8?

Author:  Mordred [ Fri Mar 16, 2012 3:50 am ]
Post subject:  Re: Security Resources

It's the 21st century! One shouldn't be using any encoding *besides* unicode (utf-8 or utf-16). It amuses me to no end how poorly supported unicode is in PHP, and if I recall correctly, they pushed full-blown utf8 support to PHP6.

Here's a good primer:


Btw, maybe you should split this discussion to a different topic so that more people would chime in.

Author:  Christopher [ Fri Mar 16, 2012 7:18 pm ]
Post subject:  Re: Using mb_convert_encoding() to convert UTF8 to UTF8

My question was about whether this technique will work with converting any encoding to itself? Or if you recommend converting to UTF8 always? It seems like the point of this is to deal with multi-byte exploits.

Author:  requinix [ Fri Mar 16, 2012 8:29 pm ]
Post subject:  Re: Using mb_convert_encoding() to convert UTF8 to UTF8

If you just want to check encoding you can use, like, as
Syntax: [ Download ] [ Hide ]
mb_detect_encoding($string, "UTF-8", true)

Or there's the regex method which is meh but works.

I'm trying to think why you might want to actually convert one encoding back into itself. It would never do anything. Maybe you're having it detect the encoding and are worried if the original encoding is UTF-8 then it might do something weird. But then that means you don't know what the original encoding is?

Author:  Mordred [ Mon Mar 19, 2012 5:44 am ]
Post subject:  Re: Using mb_convert_encoding() to convert UTF8 to UTF8


Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/