PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Nov 18, 2019 5:24 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Mar 16, 2012 12:34 am 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US
Should you use mb_convert_encoding() like you show for any character encoding you are using -- or only UTF8?

_________________
(#10850)


Top
 Profile  
 
 Post subject: Re: Security Resources
PostPosted: Fri Mar 16, 2012 3:50 am 
Offline
DevNet Resident
User avatar

Joined: Sun Sep 03, 2006 5:19 am
Posts: 1579
Location: Sofia, Bulgaria
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.


Top
 Profile  
 
PostPosted: Fri Mar 16, 2012 7:18 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US
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.

_________________
(#10850)


Top
 Profile  
 
PostPosted: Fri Mar 16, 2012 8:29 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
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?


Top
 Profile  
 
PostPosted: Mon Mar 19, 2012 5:44 am 
Offline
DevNet Resident
User avatar

Joined: Sun Sep 03, 2006 5:19 am
Posts: 1579
Location: Sofia, Bulgaria


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group