SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,530
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    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...

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


    Debbie

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,454
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    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.

  3. #3
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,530
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    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

  4. #4
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,530
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guelphdad View Post
    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

  6. #6
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you read the manual under Character sets and Collation?

  7. #7
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,530
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guelphdad View Post
    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

  8. #8
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now you know where to look in the manual.

  9. #9
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,454
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    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

    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.

  10. #10
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,530
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    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

    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?! Worrying about an international crowd, complex collations, etc is way down the road!)


    Debbie

  11. #11
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,048
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    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.
    The only code I hate more than my own is everyone else's.

  12. #12
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,530
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by oddz View Post
    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


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •