Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图将一些汉字存储到 mysql 表中。
他们变成这样:
烈火雄心
当我在 innerhtml 中输出它们时它们工作正常,但如果它是一个 html 属性,它们将不会显示中文字符。
奇怪的是,如果我将数据保存在 utf8_bin 或 utf8_unicode 中,它们就可以正常工作。
有什么解决办法吗?
更具体地说,我在执行此操作时使用了 codeIgniter。
只需确保您的桌子已准备好汉字:
转到您的 mysql 表并将“字符集”更改为“ gb2312 ”,将“排序规则”更改为“ gb2312_chinese_ci ”。
对我来说,我是在“行”级别而不是整个表上做的,因为只有我只在表的 1 个字段中期待汉字。
参考
让我知道这是否有帮助。
只需将字段的 Collation 修改为 utf8_general。