4 Replies Latest reply on May 4, 2009 3:51 PM by ATIF FAROOQ

    html entities in php via httpservice

    djsuperfive

      hi,

      i'm sending a form to a php script via httpservice.

      my problem is when i retrieve the values in PHP, the text values that have been entered in the form are formatted with HTML entities in my POST data.

      for example, the word "éléphant" is formatted as "él&eacutephant" (i'm french, so i have to deal with accents, but this problem also occurs with singles and double quotes)

      Is there a way that these special characters are not encoded with HTML entities ?

      i don't know where the problem comes from : flex, http, php ?

       

      thank you,

      max.

        • 1. Re: html entities in php via httpservice
          ATIF FAROOQ Level 3

          hi,

             when you send an http Service its contentType byDefault set to

          'application/x-www-form-urlencoded'

             there is one another option available for contentType which is

          'application/xml' in which your content will not have html entities intact

          but it will be in xml format so you will also need xml parser on the other

          end in php.Other option will be to decode urlencoded content on server side

          in php using this command

           

          html_entity_decode — Convert all HTML entities to their applicable

          characters

          string html_entity_decode ( string $string [, int $quote_style= ENT_COMPAT

          ] )

          • 2. Re: html entities in php via httpservice
            thebouv Level 2

            Quickest way to test who the culprit is:  hit your URL that you're calling in the HTTPService via another method (maybe sending a GET with test parameters in a browser) and analyzing the source.

             

            Is your server side script writing XML?  Because data that contains "special characters" will need to be wrapped in CDATA.  So if you're using a PHP library to write that XML, it might be encoding your accented characters into HTML entities to make the XML valid.

            • 3. Re: html entities in php via httpservice
              djsuperfive Level 1

              hi

              thanks for your fast response.

              i've tried the both contenttypes and the result is the same. but i haven't tried to parse xml on the php side. can i do this with simplexml in php5 or do i need something else ?

               

              i think i tried once the html_entity_decode method and it didn't work. i'll try again tomorrow.

               

              cheers,

              max.

              • 4. Re: html entities in php via httpservice
                ATIF FAROOQ Level 3

                yes you can use simplexml and load XML String with it