i have following code when i run this code on firefox its works fine giving out put as i want when i run this code on Google chrome out put not correct showing any idea?
<?php
$encode=utf8_encode("වවවවවවවවවවව");
$decode=utf8_decode($encode);
print_r($decode);
die;
?>
thanks in advance roshan
Might as well move this to answer section:
Define UTF-8 as your charset in your <head>
<meta charset="utf-8">
This code makes no sense. utf8_encode()
is a function to convert ISO-8859-1 data into UTF-8.
Googling shows that your data is a singhalese character, which isn't part of ISO-8859-1. It is extremely likely that it will be destroyed in the first utf8_encode()
call.
I guess the answer in this specific situation is, don't use utf8_encode()
. If that doesn't work for you, please provide some more context about what you are doing. Maybe you are looking for iconv()
?