开发者

charset problem on strtolower()

i'm working on a polish website. I design mysql tables and columns as utf8_general_ci and add

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

<?php uery = mysql_query("select * from messages order by id desc limit 1"); $开发者_Python百科array = mysql_fetch_array($query);

$string= $array["message"];

$string = strtolower($string);

echo "<br>$string"; ?>

result is something like "prof. dr hab. in�. boles�aw pochopie�"

so two question,

1- what is the problem why result is with unknown char? how can i fix it?

2-Is utf-8 and utf8_general_ci good for a polish website?


You have to use mb_strtolower for multibyte strings (this applies to many other string functions of php too, see manual).

Or you could request it directly from the database:

SELECT LOWER(message) FROM messages ORDER BY id desc LIMIT 1

EDIT: As for the encoding: utf8_polish_ci and utf8_general_ci are both ok.


Use mb_strtolower(), which doesn't treat one byte as one character.

If not available on your platform, you need to create it.

Have a look at Kohana 3's utf8::strotolower helper.


Use utf8_polish_ci and let MySQL do the sorting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜