Jump to content

Recommended Posts

Can anyone give a brief run down about this? I kinda understand what it is for but I dunno how would it affect my php scripts. I plan on making my own scripts and would like it to be able to handle multi-langauges so do I have to use the utf8_general_ci? Also is there any pros/cons on collation? Like any security risks or such?
Link to comment
https://forums.phpfreaks.com/topic/5705-question-about-collation/
Share on other sites

Which collation you use depends on the languages you plan to support. If you just want to support latin languages (English, French, German, Spanish, etc) latin1_general_ci should be fine. If you want to support languages like Chinese with a completely different character set, then yes utf8 is a good choice.

The collation will take care of things like comparing strings (including sorting them), but you'll still have to have the appropriate character set support in PHP (set the collation to make comparisons work, use the multi-byte string functions like mb_substr()), and on the client's browser (usually you can assume they've configured their browser to support their native language, but you have to tell the browser what you're sending it).

There are several more considerations, but I am not too familiar with it in practice, I've never done it myself.
I noticed that Wordpress and phpbb databases have it set at latin. I can type in multibyte characters and it does save it to the database and display properly when viewed because the charset of the html page is set to utf-8. But in the database, it is just scrambled letters.

I wondering more about this because I am planning to program my own CMS (to learn more about php+mysql). I just don't want to go back and mess with it or start from scratch again.

I also did some thinking and there would be a problem if I use utf-8 in the database. Like for username there is an ascii letter 'a' but there is also an unicode letter 'a' which would be a problem.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.