character encoding - write a php function which works for any lanuage -


i'm writing function clear text works or without ut8 characters.

i keep getting text this.

coventry salary - �25,000 - �35,000  

but function removes � leaves other.

i want know if wrote function cleans text.

function converthtmlspecialchars ( $str='' )  {     $str = htmlspecialchars ( $str );     $str = mb_convert_encoding($str, 'utf-8', mb_detect_encoding($str));     $str = htmlspecialchars($str, ent_noquotes, 'utf-8');     return $str; } 

this function:

$str = mb_convert_encoding($str, 'utf-8', mb_detect_encoding($str)); 

just tries detect character set $str; if finds $str contains utf8 characters return "utf8" func actually:

$str = mb_convert_encoding($str, 'utf-8', 'utf-8'); 

which doesnt much.. in opinion you should give character set of string hand. example, if turkish: iso-8859-5, if greek: iso-8859-7 , so..


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

javascript - Preserving URL fragment through CAS sign-on -

asp.net mvc - Implementing normal user/pass, Twitter & Facebook auth -