I am currently moving blog posts from wordpress to drupal. however after moving it
some of the text is not being displayed correctly.
wordpress is displaying :
When it hasnât (html code is <h2>When it hasnât</h2>)
Drupal is displaying :
When it hasnââ¬â¢t (html code is <h2>When it hasnââ¬â¢t</h2>)
In the wordpress and drupal db the value is correct. The source is the same.
<h2>When it hasnââ¬â¢t</h2>
I did a search and found many options. None of them helped.
Below are the ones I have done and checked.
1) I double checked that utf-8 is the character encoing in drupal and wp.
I also made a simple test.php file to check nothing else was coming in the way
and it still did not display correctly.
2) I made sure when we take a mysqldump and upload to drupal utf-8
is used.
3) I also made sure the .php file is in utf-8 when saved.
4) I changed the encoding type in chrome for every option available and nothing
displayed it correctly.
5) I also used php functions to recode it but they did not work.
$value2="<h2>When it hasnââ¬â¢t</h2>";
$out = recode_string('..utf-8', $value2);
//output - When it hasnt
$out2= mb_convert_encoding($value2,'UTF-8', "UTF-8");
// output - When it hasnâââ‰â¢t
$out3= @iconv('UTF-8', 'utf-8', $value2);
// output - When it hasnâââ‰â¢t
I have ran out of options now and I am stuck. Please help
You say the text in both databases is correct, but actually this doesn’t mean too much: to viewing the content of a record you must use some client, and quite a few transformations may happen depending on how the text is rendered so you can read it.
So only two things matters:
Since your page outputs
ââ¬â¢
(in CP1252 is xE2x80x99) forâ
(Unicode U+2019, UTF-8 is 0xE28099) I guess the column is indeed UTF-8, however there’s someone between the database and the browser who thinks the text is CP1252. This is what you have to check:SET NAMES 'UTF-8'
. Note that if you don’t need the Unicode set, you can even use CP1252: the only important thing is that you know the encoding, since PHP strings are just byte arrays.Content-Type
header. I mean, configure Drupal to callheader('Content-Type: text/html; charset=utf-8');