【问题标题】:Django ascii displaying errorDjango ascii 显示错误
【发布时间】:2012-07-09 09:48:29
【问题描述】:

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

【问题讨论】:

标签: django view asciiencoding


【解决方案1】:

我猜你错过了模板中的内容类型元标记:

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

【讨论】:

  • 我也保留了那个标签。我通过解码为 utf-8 来修复它
猜你喜欢
  • 1970-01-01
  • 2011-12-08
  • 2021-05-03
  • 2012-10-26
  • 2012-04-30
  • 2012-07-30
  • 2020-12-09
  • 2014-08-05
  • 1970-01-01
相关资源
最近更新 更多