utf8 output from database

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

    #1

    utf8 output from database

    Hi,

    I'm having problems outputting data from my MySQL database. The output
    should be Playa del inglés but instead I get ... Playa Del Ingl?s. I've
    tried utf8_encode(), but this just converts to Playa Del Inglã©s.

    Any advice? It seems to show fine in PHPMyadmin.

    Thanks


  • Jerry Stuckle

    #2
    Re: utf8 output from database

    elyob wrote:[color=blue]
    > Hi,
    >
    > I'm having problems outputting data from my MySQL database. The output
    > should be Playa del inglés but instead I get ... Playa Del Ingl?s. I've
    > tried utf8_encode(), but this just converts to Playa Del Inglã©s.
    >
    > Any advice? It seems to show fine in PHPMyadmin.
    >
    > Thanks
    >
    >[/color]

    Hi, elyob,

    Are you using an HTML charset that displays the "é"?

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • elyob

      #3
      Re: utf8 output from database


      "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
      news:-sOdnTzUavOEb-TeRVn-pQ@comcast.com. ..[color=blue]
      > elyob wrote:[color=green]
      >> Hi,
      >>
      >> I'm having problems outputting data from my MySQL database. The output
      >> should be Playa del inglés but instead I get ... Playa Del Ingl?s. I've
      >> tried utf8_encode(), but this just converts to Playa Del Inglã©s.
      >>
      >> Any advice? It seems to show fine in PHPMyadmin.
      >>
      >> Thanks[/color]
      >
      > Hi, elyob,
      >
      > Are you using an HTML charset that displays the "é"?[/color]

      I thought so ...


      Comment

      • elyob

        #4
        Re: utf8 output from database


        "elyob" <newsprofile@gm ail.com> wrote in message
        news:4379f7a5$1 @news1.homechoi ce.co.uk...[color=blue]
        >
        > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
        > news:-sOdnTzUavOEb-TeRVn-pQ@comcast.com. ..[color=green]
        >> elyob wrote:[color=darkred]
        >>> Hi,
        >>>
        >>> I'm having problems outputting data from my MySQL database. The output
        >>> should be Playa del inglés but instead I get ... Playa Del Ingl?s. I've
        >>> tried utf8_encode(), but this just converts to Playa Del Inglã©s.
        >>>
        >>> Any advice? It seems to show fine in PHPMyadmin.
        >>>
        >>> Thanks[/color]
        >>
        >> Hi, elyob,
        >>
        >> Are you using an HTML charset that displays the "é"?[/color]
        >
        > I thought so ...[/color]
        <meta http-equiv="content-type" content="text/html;charset=ut f-8" />


        Comment

        • Jerry Stuckle

          #5
          Re: utf8 output from database

          elyob wrote:[color=blue]
          > "elyob" <newsprofile@gm ail.com> wrote in message
          > news:4379f7a5$1 @news1.homechoi ce.co.uk...
          >[color=green]
          >>"Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
          >>news:-sOdnTzUavOEb-TeRVn-pQ@comcast.com. ..
          >>[color=darkred]
          >>>elyob wrote:
          >>>
          >>>>Hi,
          >>>>
          >>>>I'm having problems outputting data from my MySQL database. The output
          >>>>should be Playa del inglés but instead I get ... Playa Del Ingl?s. I've
          >>>>tried utf8_encode(), but this just converts to Playa Del Inglã©s.
          >>>>
          >>>>Any advice? It seems to show fine in PHPMyadmin.
          >>>>
          >>>>Thanks
          >>>
          >>>Hi, elyob,
          >>>
          >>>Are you using an HTML charset that displays the "é"?[/color]
          >>
          >>I thought so ...[/color]
          >
          > <meta http-equiv="content-type" content="text/html;charset=ut f-8" />
          >
          >[/color]

          I'm going to show my ignorance of foreign languages here - is this
          Italian, French or what? And what's the hex value of the character?

          I have seen other problems like this; it's generally the charset isn't
          set up to display that particular character. And I'm not sure UTF-8
          will do it.


          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Jerry Stuckle

            #6
            Re: utf8 output from database

            elyob wrote:[color=blue]
            > "elyob" <newsprofile@gm ail.com> wrote in message
            > news:4379f7a5$1 @news1.homechoi ce.co.uk...
            >[color=green]
            >>"Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
            >>news:-sOdnTzUavOEb-TeRVn-pQ@comcast.com. ..
            >>[color=darkred]
            >>>elyob wrote:
            >>>
            >>>>Hi,
            >>>>
            >>>>I'm having problems outputting data from my MySQL database. The output
            >>>>should be Playa del inglés but instead I get ... Playa Del Ingl?s. I've
            >>>>tried utf8_encode(), but this just converts to Playa Del Inglã©s.
            >>>>
            >>>>Any advice? It seems to show fine in PHPMyadmin.
            >>>>
            >>>>Thanks
            >>>
            >>>Hi, elyob,
            >>>
            >>>Are you using an HTML charset that displays the "é"?[/color]
            >>
            >>I thought so ...[/color]
            >
            > <meta http-equiv="content-type" content="text/html;charset=ut f-8" />
            >
            >[/color]

            One other thing - what happens if you use iso-8859-1?

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • Sander Tekelenburg

              #7
              Re: utf8 output from database

              In article <L8idne-6U7PDiOfeRVn-rQ@comcast.com> ,
              Jerry Stuckle <jstucklex@attg lobal.net> wrote:

              [...]
              [color=blue]
              > I have seen other problems like this; it's generally the charset isn't
              > set up to display that particular character. And I'm not sure UTF-8
              > will do it.[/color]

              The charset parameter doesn't 'do' anything. It simply claims which
              character repertoire applies. If the content is utf-8, the charset
              should say so. If the content is for example mac-roman, claiming
              "charset=ut f-8" doesn't *make* it utf-8. You'll need to transliterate to
              utf-8 first.

              Thus, you need to always, in this order,
              - know what character repertoire your original content is in
              - optionally transliterate to another character repertoire
              - ensure all tools you use handle that character repertoire properly
              - provide the correct charset value to let user-agents know how to
              handle the data

              --
              Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>

              Mac user: "Macs only have 40 viruses, tops!"
              PC user: "SEE! Not even the virus writers support Macs!"

              Comment

              • Andy Hassall

                #8
                Re: utf8 output from database

                On Tue, 15 Nov 2005 14:59:17 -0000, "elyob" <newsprofile@gm ail.com> wrote:
                [color=blue]
                > <meta http-equiv="content-type" content="text/html;charset=ut f-8" />[/color]

                PHP is a server-side programming language, and so is capable of outputting
                real HTTP headers. These are by far more preferable to meta Content-type
                headers, which are more useful for storage media that don't have separate
                metadata - i.e. when just dumped to a filesystem.

                <?php header("Content-type: text/html;charset=ut f-8"); ?.

                ... is much more likely to cause the browser to accept the encoding of the
                page as UTF-8.

                --
                Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
                http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

                Comment

                • Andy Hassall

                  #9
                  Re: utf8 output from database

                  On Tue, 15 Nov 2005 12:05:32 -0000, "elyob" <newsprofile@gm ail.com> wrote:
                  [color=blue]
                  >I'm having problems outputting data from my MySQL database. The output
                  >should be Playa del inglés but instead I get ... Playa Del Ingl?s. I've
                  >tried utf8_encode(), but this just converts to Playa Del Inglã©s.
                  >
                  >Any advice? It seems to show fine in PHPMyadmin.[/color]

                  What is the encoding of the page in PHPMyAdmin?

                  (Right click, View Page Info in Firefox)

                  How does the character appear in the page source in PHPMyAdmin? Is it encoded
                  as an HTML character entity (&eacute; or something like that), or output
                  directly?

                  The key with solving character encoding issues is knowing exactly how
                  characters have been stored and encoded at every point in the system - from
                  initial input, stored in the database, any conversions on fetching from the
                  database, and on output to the final page. Once you lose track of the encoding
                  then you are in trouble.
                  --
                  Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
                  http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

                  Comment

                  Working...