【问题标题】:Html Text-area: problems with accented lettersHtml 文本区域:重音字母的问题
【发布时间】:2014-04-14 21:37:58
【问题描述】:

标签: html mysql servlets utf-8 character-encoding


【解决方案1】:

更改现有表以使用 UTF-8 字符集:

ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

将数据库的默认字符集设置为 UTF8 用于您将来创建的表:

ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci;

您可以使用utf8_general_ciutf8_unicode_ciWhat's the difference between utf8_general_ci and utf8_unicode_ci 解释说,它们在排序的速度和准确性上存在差异,utf8_unicode_ci 更准确,使用utf8_general_ci 的性能提升非常小。

(另外,请注意,当您在命令提示符下在 mysql 控制台中进行查询时,即使正确存储,它也不会显示为 UTF-8。这是命令提示符的限制。)

【讨论】:

  • 这是我拼图中缺少的一块——谢谢。对于在这部分苦苦挣扎的其他人,以及在 mySQL 中读/写重音字符,请务必在连接后包含最后的 UTF-8 行:$dbs = mysql_pconnect($dbsServer,$dbsUsername,$dbsPassword); mysql_select_db($dbsName, $dbs); mysql_set_charset('utf8',$dbs);
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-13
  • 2019-11-03
  • 2011-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多