I have to save russian language product description in db. So for that I converted that string to utf 8 using below code,
$data = 'Это русский';
$cData = iconv(mb_detect_encoding($data, mb_detect_order(), true), "UTF-8", $data);
It is working fine. But I need to get that data back, and I don't know how to decode it again. I tried below one, but it is not working,
$des = $object->getDescription("ru");
$enc = mb_detect_encoding($des, "UTF-8,ISO-8859-1");
echo iconv($enc, "UTF-8", $des);
and I tried below one, but not working
utf8_decode ( $data );
Can any one tell me how to decode this ?
Update:
I tried below one to encode,
$data = 'Это русский';
$cData = htmlentities($data, ENT_COMPAT, 'UTF-8');
It's working fine, But how to decode this ?
I tried below one, but it is not working..
$des = $object->getDescription("ru");
echo $cData = htmlentities($des, ENT_COMPAT, 'UTF-8');