Need to define Character Set?

Should I define my Character Set in my MySQL connect script (as opposed to not defining it at all)?

Like this…


// Define Character Set.
mysqli_set_charset($dbc, 'utf8');

Debbie

If you don’t set it, it will set to the default.

IMHO it’s best to pick one and use it everywhere consistantly - database, text editors, files etc. - everywhere.

Isn’t UTF-8 the default anyways?

How do I define it across the board?

I guess for the database portion I set it as described.

What about in my PHP files?

Web Server?

Other places?

Debbie

Latin 1 is default I believe. If you want to set one by default you’d do that in your my.ini file and restart the mysql server.

What is the difference between UTF-8 and Latin-1?

Which Character Set would I want anyways?

Debbie

Did you read the manual under Character sets and Collation?

I don’t eve know what Collation is?! :-/

And, no, I didn’t check the manual. Not sure where to even start looking, so I asked here.

Debbie

Now you know where to look in the manual.

The following is a gross understatement, so don’t hesitate to read the MySQL documentation which, IMHO, is pretty good compared to some.

If you are planning on only ever storing the “128 American keyboard” characters, you probably don’t need to worry about it much, though of course the more you know the better :wink:

But as soon as you go outside of these, from “fancy quotes” to umlauts and tildes to Chinese glyphs, etc. then the character set becomes more important.

I think UTF-8 is a wise choice and covers most languages and characters you’re likely to ever use.

Collation is important if you plan on having text searches of the database. I don’t have a real example, but as I understand it, say that in most langauges
“a” is “less than” “e”, there may be a language where the character “e” comes first, so the query would fail. Again, if you know you won’t ever be working with anything other than American English, it’s probably not worth fretting about.

All things in phases…

(If I could get 20 visitors to my website every day I’d me elated?! :rolleyes: Worrying about an international crowd, complex collations, etc is way down the road!)

Debbie

Anticipating things up front saves time, money and not to mention headaches. A few months from now you might even remember why or what you wrote. So prime time to add things is in the beginning, when your fully focused/knowledgeable in all decisions that have been made. Adding things later generally can not be avoided but anticipation of as many things up-front as possible will alleviate bugs and what not down the road. Especially if your working on your own personal project where cost is not a factor.

So what do you use for your MySQL instances and why?

Debbie