簡體   English   中英

來自mysql的html中的特殊字符輸出

[英]Special character output in html from mysql

我在Wordpress中使用一個插件,在一個字段中存儲一些HTML代碼。 mediumtext utf8_general_ci

當我想輸出這些信息時,所有特殊字符,如" ´ ' ...和其他一些字符顯示為黑色鑽石,里面有問號

當插件顯示此文本時,它是完美的。 這是在頭腦中:

<meta charset="UTF-8" />

當我在其他地方輸出時,我的頭腦中有這個,所有這些字符都丟失了:

<meta http-equiv="content-type" content="text/html; charset=utf-8"/>

字符正確存儲在MYSQL中,我通過PHP輸出它

ob_start();?>
some html
<?php echo $row4['details'];?> <- this is the field im talking about
some html
<?php
$details = ob_get_clean();

后來只是:

echo $details;

我已經閱讀了足夠的內容,並且總是提到字符集,但我認為我的還可以。

謝謝您的幫助!

編輯:添加完整示例

WP中顯示的文字。 正如我在評論中所說,這可能是由編輯將MS Word復制/粘貼到Worpress中。

8. Choose the verb to complete the sentence.

______ you ever _____ the proverb, “Time is gold”?
 Has… heard…
 Have… hear…
 Have… heard…

像這樣存儲在數據庫中(不要查看正確/正確的用戶答案)

<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>

從數據庫中顯示的文本(我正在進行的工作)

8. Choose the verb to complete the sentence.

______ you ever _____ the proverb, �Time is gold�?

    Has� heard�
    Have� hear�
    Have� heard�

由於Kirit Patel,在utf8_encode()之后顯示的文字

8. Choose the verb to complete the sentence.

______ you ever _____ the proverb, Time is gold?

    Has heard
    Have hear
    Have heard

我剛發現角色還在那里。 編輯時我可以看到一個帶數字的框(未在預覽中顯示)。

像這樣的東西 字符

你可以像使用一樣

<?php 

echo utf8_encode($row4['details']);
?>

希望這對你有所幫助。

這里討論“黑鑽石”。 “Someting like this”顯示0093 ,這是一個無效的utf8代碼,用於某種引用的味道; 另一方面,hex 93,解釋為latin1

你能簡單地切換到ascii引號和撇號嗎?

否則,您需要始終使用utf8 - 從生成十六進制93的任何內容開始。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM