我在做一个波兰网站。我将mysql表和列设计为utf8_general_ci并添加
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<?php uery = mysql_query("select * from messages order by id desc limit 1"); $array = mysql_fetch_array($query);
$string= $array["message"];
$string = strtolower($string);
echo "<br>$string"; ?>
结果类似于"prof. dr hab. in�. boles�aw pochopie�"
所以有两个问题
1-结果带有未知字符的问题是什么?我怎么才能修复它?
2- utf-8和utf8_general_ci对波兰网站有好处吗?
发布于 2011-03-05 08:23:02
你必须对多字节字符串使用mb_strtolower (这也适用于php的许多其他字符串函数,参见manual)。
或者,您可以直接从数据库请求它:
SELECT LOWER(message) FROM messages ORDER BY id desc LIMIT 1编辑:至于编码:utf8_polish_ci和utf8_general_ci都可以。
发布于 2011-03-05 08:35:03
使用mb_strtolower(),它不会将一个字节视为一个字符。
如果在您的平台上不可用,则需要创建它。
发布于 2011-03-05 08:54:13
使用utf8_polish_ci并让MySQL进行排序。
https://stackoverflow.com/questions/5200699
复制相似问题