开发者

Varchar for UTF-8?

I found a similar post about this but still not sure.

As I am making my guestbook and so forth multi-language I changed the collation to uft8_unicode_ci in mysql, everything works as it should, something that I did not think of was the type I use, my guestbook is multi-language and for the name field a user cannot enter 开发者_如何学运维more than 50 characters, same for subject and 800 characters for guestbook message.

Now doing this check in PHP is straight forward ie. checking string length using the mb_ before strlen etc.

But I am concerned that data maybe truncated in mysql. Obviously normal characters will be ok but when it's Chinese characters and other non-standard characters obviously this is a concern for me as i don't know how varchar will calculate them.


Since mySQL 4.1, VARCHAR counts in characters instead of bytes.

You can safely specify a VARCHAR(255) type for a message field that needs to hold 255 characters.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜