php засичане енкодинг на текст

function detect_encoding($string)
{
return strtolower(mb_detect_encoding(„$string“,’utf-8,windows-1251′));
}//End of detect_encoding($string)

$string=“мартин петров“;#stringa e windows1251;
echo detect_encoding($string);
//Shte wyrne windows-1251, ako stringa e utf-8 shte wyrne utf-8

 

function cp1251_to_utf8($s)
{
if ( mb_check_encoding(„$s“,“cp1251″) == 1){return iconv(„cp1251″,“utf8“,$s);}else { return $s; };
}
function utf8_to_cp1251($s)
{
if ( mb_check_encoding(„$s“,“utf-8″) == 1){return iconv(„utf8″,“cp1251“,$s);}else{return $s;}
}//End of utf8_to_cp1251($s)

Категория:

Logged in as {{omniform_current_user_display_name}}. Edit your profile. Log out? Required fields are marked *

Your email address will not be published. Required fields are marked *

Comments are closed.

You must be logged in to post a comment.