2012-07-09 95 views
2

的Ascii解碼錯誤Django的ASCII顯示錯誤

文本= "Hanuman (Sanskrit: हनुमान्, Hanumān), a Hindu deity who was an ardent devotee of Rama according to Hindus legends, and a central character in the Indian epic Ramayana."

我保存的文本到MySQL表novarchar柱,它成功地插入。

當我在控制檯中檢索到這些數據時,它顯示正確。但是,當我試圖通過Django檢索它並將其顯示在模板中時,它顯示爲一些ascii字符。

顯示爲"Hanuman (Sanskrit: हनà¥à¤®à¤¾à¤¨à¥, HanumÄn), is a Hindu deity who is an ardent devotee of Rama, a central character in the Indian epic Ramayana."

+2

請出示一些代碼。模型是什麼樣的?你如何獲取數據?你如何在模板中顯示它?你是如何將它插入的? – 2012-07-09 09:57:39

+1

https://docs.djangoproject.com/zh/dev/ref/unicode/ 請看看 – Khaleel 2012-07-09 10:01:38

回答

0

我猜你錯過了內容類型元標記您的模板:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
+0

我也保存了這個標籤。我通過解碼到utf-8來修復它 – 2012-07-27 06:35:00