Home arrow Archives arrow Software Tutorials arrow MySQL database Character Set, and 'Collation'

MySQL database Character Set, and 'Collation'

PDF  | Print |  E-mail
(1 vote)
Written by ultrabeast   
Friday, 04 July 2008
MySQL database character set, and 'collation'

a.k.a.

Finally, the answers to MySQL database questions about which character set to use, what's the difference between character set, and what's collation and which one to use?


Read More...

Since we're already here, I might as well show you too that we should take a look around here in PHPMyAdmin and we want to see that:
  • MySQL charset: UTF-8 Unicode (utf8)
  • If you plan on using Asian characters such as Japanese and Chinese in your database, then make sure these (everywhere possibly mentioned) are set to UTF-8 Unicode (utf8) .

    And now a FAQ answered here: UTF-8 General_ci  is also ok, but there's some difference when searching through a database in terms of the ascending/descending/character value equality sort and search ordering.
    ( _ci means 'case insensitive'.)

    Just in case you're curious and wanted to know... It took me a long time of searching to find out, though... just another one of those things that don't make a significant difference to my life even when I know it, but when I don't know it, I just can't let go of it. (Sigh...)

    What's more relevant, and more likely, though, is that the tables in your database would most probably show latin1_swedish_ci especially on your remote webhost, as a default. 
    FAQ reason: this is because MySQL AB is a Nordic company.

    That just means that the data is being stored in your database as single-byte ASCII characters, and not as double-byte Unicode characters.

    Keep in mind that there are two places where charset is used
    • charset used for Collation
    • charset used Data actually stored in your database!
     
    And that's just about the collation: that's just how the database fetches data stored in your database.
     
    This is not all, when you actually create your database, you have to make sure that for future lack of headaches, you have to make sure the data itself that is stored in your database is also in UTF-8 Unicode.
    By default, perhaps many webhost Cpanels will create your database to store in latin1_swedish_ci. You may need to take some manual steps to make everything UTF-8 Unicode, which I do know and have done before. I'll just say, just buzz me, supposing if you had actually decided to do all of the above for yourself!
     
    So do we actually need to care about all that? Thankfully, I would say no, even if your database is not set to store in unicode but in latin1_swedish, you can still store and serve Japanese characters on your Joomla site, for the most part. Only some things like post titles might not be readily shown as Japanese characters but as gibberish, but this depends on your browser - usually IE screws this up. So if you are not incorrigibly obsessive-compulsive, then 99.9% of the time, you can live a happy life not bothering about all this.

    Unless you want to directly enter Asian text in your database through the PMA interface and not through the Joomla interface, then it would be better if it's specified that your tables are storing data as Unicode characters.
     
     
    And there you have it! A local webhost server for you to test your PHP scripting, Joomla, Wordpress and stuff on, before doing the same for your live site. (Or actually deciding that you actually want to have one, now.)
    Comments
    Add New Search RSS
    Divine Fang     |2008-07-05 00:29:47
    avatar
    Quote:
    FAQ reason: this is because MySQL AB is a Nordic company.

    OOOOOOOOOOOh... so desu ka....

    Quote:
    Only some things like post titles might not be readily shown as Japanese characters but as gibberish, but this depends on your browser - usually IE screws this up.

    Yeah... hate it!

    Quote:
    even if your database is not set to store in unicode but in latin1_swedish, you can still store and serve Japanese characters on your Joomla site, for the most part.

    Not only Joomla, everything else should work too.
    ultrabeast   |2008-07-05 07:14:46
    avatar
    Quote:
    Not only Joomla, everything else should work too.


    Yup.. coz whatever characters inside the database regardless of their encoding inside the db is collated and fetched out as UTF-8.. just need to ensure that your site template's charset is also set to UTF-8, as mentioned in another comment.

    But I guess most commercial blog services like blogger, xanga, multiply, would already have their default template's charset set as UTF-8 already. So only people who are into doing their own site templates or checking/modifying other ppl's need worry..
    ultrabeast   |2008-07-05 07:27:12
    avatar Just to add to the article - to those who want to use non-English characters - not only Asian languages, but also German, French, Norsk etc. in their website, not only should they set their MySQL DB as mentioned, but also ensure in their website template that the webpage itself is not encoded in the default iso-8859-1 charset, but as "UTF-8".

    Check for this line in your page source
    and ensure charset is UTF-8:

    meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
    Write comment
    Name:
    Email:
     
    Website:
    Title:
    UBBCode:
    [b] [i] [u] [url] [quote] [code] [img] 
     
     
    :angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
    :(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
    :!::?::idea::arrow:
     
    Please input the anti-spam code that you can read in the image.

    3.22 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."


    Tags:  tutorial, WAMP, MySQL, PHPMyAdmin, MySQL character set, collation
     
    Next >
    Advertisement

    Random Item

    Latest Comments!

    RSS Syndication


    Save to FireFox Live Bookmarks:
    feed-icon-12x12-orange.gif
    View Feed XML

    Search I, UltraBeast!

    ShoutMix CB


    Say No to Internet Explorer!

    - This site will give an "Operation Aborted" error with IE whenever there are photo galleries on the page.

    - MOZILLA FIREFOX is the recommended browser.

    - Let me know if there are problems with Opera, Safari, etc.
    Thanks ~

    Problems Registering?

    If you have problems getting your activation email, fret not:
    • Simply log in below using your Username and Password to get that mail sent again to you.
    • Check your bulk/junk/trash mail.
    • Rinse and repeat as many times as necessary.
    Should all else fail - I can be contacted at
    Email webmaster

    Login





    Live Traffic Feed

    Who's Online

    No Users Online
    © 2008 Interview With The UltraBeast
    Joomla! is Free Software released under the GNU/GPL License.