PHP + Unicode

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • willwudan@gmail.com

    PHP + Unicode

    Hi all,

    I have saved some data in a MySQL database as UTF-8 format. But when I
    tried
    to read the data using PHP, the webpage gave me all the "?"s. How to
    read it
    multilingual data correctly in PHP?


    I believe there must be a way since I can see the words in UTF-8 in the

    phpmyadmin interface. phpmyadmin is also coded in PHP and if it can do
    it,
    there must be a way to read multilingual data properly.

    Anyone knows how to do it? Thanks a lot!

    --Dan

  • Alvaro G Vicario

    #2
    Re: PHP + Unicode

    *** willwudan@gmail .com wrote/escribió (25 Aug 2005 22:27:20 -0700):[color=blue]
    > I have saved some data in a MySQL database as UTF-8 format. But when I
    > tried
    > to read the data using PHP, the webpage gave me all the "?"s. How to
    > read it
    > multilingual data correctly in PHP?[/color]

    Have you set the appropriate headers to tell browser what charset it should
    use to decode? It may not be the solution but it's a necessary step. Rather
    than:

    Content-Type: text/html; charset=ISO-8859-1

    tell it's UTF-8.



    --
    -- Álvaro G. Vicario - Burgos, Spain
    -- http://bits.demogracia.com - Mi sitio sobre programación web
    -- Don't e-mail me your questions, post them to the group
    --

    Comment

    • willwudan@gmail.com

      #3
      Re: PHP + Unicode

      Yes, I set the appropriate headers to tell the browser it is UTF-8. But
      it does not help!


      Alvaro G Vicario wrote:
      [color=blue]
      >
      > Have you set the appropriate headers to tell browser what charset it should
      > use to decode? It may not be the solution but it's a necessary step. Rather
      > than:
      >
      > Content-Type: text/html; charset=ISO-8859-1
      >
      > tell it's UTF-8.
      >
      >
      >
      > --
      > -- Álvaro G. Vicario - Burgos, Spain
      > -- http://bits.demogracia.com - Mi sitio sobre programación web
      > -- Don't e-mail me your questions, post them to the group
      > --[/color]

      Comment

      • Oliver Grätz

        #4
        Re: PHP + Unicode

        Try this before you output anything:

        mb_http_output( "UTF-8");
        ob_start("mb_ou tput_handler");

        It automagically converts to UTF-8. Other suggestion:
        Have you set the Default-Charset in your httpd.conf? If I recall
        correctly it overrides anything in your script if it is set.

        AllOlli

        Comment

        Working...