Character encoding to UTF-8

 

header('Content-Type: text/html; charset=utf-8');

ini_set("default_charset", "UTF-8");

mb_internal_encoding("UTF-8");


function clean($string) {

   $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.

   return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.

 }


 function clean4($string) {

   //$string = mb_convert_encoding($string, 'UTF-16LE', 'UTF-8');

   //$string = iconv(mb_detect_encoding($string, mb_detect_order(), true), "UTF-8", $string);

   $string = trim(ltrim(ltrim($string,":"),"-"));

   //return preg_replace('/[^A-Za-z0-9\-]/', ' ', trim($string));

   return trim($string);

 }


function isUTF8($string) {

    return (utf8_encode(utf8_decode($string)) == $string);

}

function replace_unicode_escape_sequence($match) {

return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');

}


$string = iconv(mb_detect_encoding($string, mb_detect_order(), true), "UTF-8", $string);


htmlspecialchars_decode(htmlspecialchars(get_the_title($postID), ENT_QUOTES, 'UTF-8'));

0 comments :