Reputation: 69
I am using a plugin in Wordpress that stores some html code in a field.
This column is mediumtext utf8_general_ci
When I want to output this information all special characters such as " ´ ' ...
and some others are displayed as black diamonds with a question mark inside �
When the plugin shows this text it's perfect. This is in the head:
<meta charset="UTF-8" />
When I output elsewhere I have this in my head and all those characters are lost:
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
Characters are properly stored in MYSQL, and I output it via PHP like this
ob_start();?>
some html
<?php echo $row4['details'];?> <- this is the field im talking about
some html
<?php
$details = ob_get_clean();
and later just:
echo $details;
I have read quite enough and the charset is always mentioned, but I think mine is OK.
Thanks for the help!
Edit: Adding Full example
Text shown in WP. As I said in a comment this might have been copy/pasted from MS Word into Worpress by an editor.
8. Choose the verb to complete the sentence.
______ you ever _____ the proverb, “Time is gold”?
Has… heard…
Have… hear…
Have… heard…
Stored in database like this (don't look into correct/user answer that works properly)
<span class='watupro_num'>8. </span>Choose the verb to complete the sentence.</p>
<p>______ you ever _____ the proverb, “Time is gold”?</p></div>
<ul>
<li class='answer'><span class='answer'>Has… heard…</span></li>
<li class='answer user-answer'><span class='answer'>Have… hear…</span></li>
<li class='answer correct-answer'><span class='answer'>Have… heard…</span></li>
</ul>
Text shown out of database (what im working on)
8. Choose the verb to complete the sentence.
______ you ever _____ the proverb, �Time is gold�?
Has� heard�
Have� hear�
Have� heard�
Text shown after utf8_encode()
thanks to Kirit Patel
8. Choose the verb to complete the sentence.
______ you ever _____ the proverb, Time is gold?
Has heard
Have hear
Have heard
I've just discovered characters are still there. I can see a box with numbers while editing (not displayed in preview).
Upvotes: 3
Views: 269
Reputation: 142540
"Black diamonds" are discussed here . The "Someting like this" shows 0093
, which is an invalid utf8 code for some flavor of quote; on the other hand, hex 93, interpreted as latin1 is “
.
Can you simply switch to ascii quotes and apostrophes?
Otherwise, you need to use utf8 throughout -- starting with whatever is generating the hex 93.
Upvotes: 0
Reputation: 122
You can use just like
<?php
echo utf8_encode($row4['details']);
?>
Hope this helps you.
Upvotes: 4