Character Sets in PHP + MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin Laurence

    Character Sets in PHP + MySQL

    Can anyone advise me on the use of UTF-8 in PHP and MySQL? What is the best
    approach?

    I would prefer to store HTML extended characters in the database as UTF-8,
    but I can only get the HTML to display properly if I store character
    entities (eg. ř).

    Every table in my database is set to UTF-8. The web page generated by PHP is
    declared as UTF-8. The HTTP response header from the server is UTF-8. The
    character set of the database connection is defined as UTF-8.

    I've tried using the PHP function "htmlentiti es" to convert the characters,
    but it doesn't work for the complete UTF-8 character set.

    What am I missing? Do I need to do something with the Multibyte string
    functions?


  • Juliette

    #2
    Re: Character Sets in PHP + MySQL

    Kevin Laurence wrote:[color=blue]
    > Can anyone advise me on the use of UTF-8 in PHP and MySQL? What is the best
    > approach?
    >
    > I would prefer to store HTML extended characters in the database as UTF-8,
    > but I can only get the HTML to display properly if I store character
    > entities (eg. ř).
    >
    > Every table in my database is set to UTF-8. The web page generated by PHP is
    > declared as UTF-8. The HTTP response header from the server is UTF-8. The
    > character set of the database connection is defined as UTF-8.
    >
    > I've tried using the PHP function "htmlentiti es" to convert the characters,
    > but it doesn't work for the complete UTF-8 character set.
    >
    > What am I missing? Do I need to do something with the Multibyte string
    > functions?
    >
    >[/color]
    Are you sending a header which tells the browser you will be sending it
    UTF-8 ?
    header('Content-Type: text/html; charset=utf-8');

    In the HTML you could also add:
    <meta http-equiv="Charset" content="UTF-8" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    Comment

    • Kevin Laurence

      #3
      Re: Character Sets in PHP + MySQL

      Yes. The response header includes 'Content-Type: text/html; charset=utf-8'.

      "Juliette" <jrf_no_spam@jo keaday.net> wrote in message
      news:438fb9c4$0 $61092$dbd4f001 @news.wanadoo.n l...[color=blue]
      > Kevin Laurence wrote:[color=green]
      >> Can anyone advise me on the use of UTF-8 in PHP and MySQL? What is the
      >> best approach?
      >>
      >> I would prefer to store HTML extended characters in the database as
      >> UTF-8, but I can only get the HTML to display properly if I store
      >> character entities (eg. ř).
      >>
      >> Every table in my database is set to UTF-8. The web page generated by PHP
      >> is declared as UTF-8. The HTTP response header from the server is UTF-8.
      >> The character set of the database connection is defined as UTF-8.
      >>
      >> I've tried using the PHP function "htmlentiti es" to convert the
      >> characters, but it doesn't work for the complete UTF-8 character set.
      >>
      >> What am I missing? Do I need to do something with the Multibyte string
      >> functions?[/color]
      > Are you sending a header which tells the browser you will be sending it
      > UTF-8 ?
      > header('Content-Type: text/html; charset=utf-8');
      >
      > In the HTML you could also add:
      > <meta http-equiv="Charset" content="UTF-8" />
      > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />[/color]


      Comment

      Working...