Loading ...
Sorry, an error occurred while loading the content.

RE: [soaplite] wrong encoding (perhabs caused by utf8?)

Expand Messages
  • Maurice McCabe
    The XML standard requires that certain characters contained within the XML document content be escaped. Otherwise it is not a legal XML document. I use the
    Message 1 of 7 , Jul 20, 2004
    • 0 Attachment
      Message
      The XML standard requires that certain characters contained within the XML document content be escaped. Otherwise it is not a legal XML document. I use the following subroutine to do the substitution. It only contains the values I needed to escape. There may be other values not included in my list.
       
      sub escape {
          # must escape certain characters or the XML document is invalid
          my ($str) = @_;
          $str =~ s/</&lt;/g;
          $str =~ s/>/&gt;/g;
          $str =~ s/&/&amp;/g;
          $str =~ s/"/&quote;/g;
          $str =~ s/'/&apos;/g;
       
          # strip out invalid characters (according to Mircosoft)
          #$str =~ s/[:\-\n\r()]//g;

          return $str;
      }
       
      Regards,
       
      Maurice
      -----Original Message-----  
      From: Duncan Cameron [mailto:duncan_cameron2002@...]
      Sent: Tuesday, July 20, 2004 8:33 AM
      To: Marten Lehmann; soaplite@yahoogroups.com
      Subject: Re: [soaplite] wrong encoding (perhabs caused by utf8?)

      At 2004-07-20, 16:22:06 Marten Lehmann <lehmann@...> wrote:

      >Hello,
      >
      >I did some experiments, but I couldn't solve the problem. I installed
      >the latest SOAP-Lite (0.60a) on client and server, but I still get e.g.
      >
      >&amp;euro;
      >
      >instead of &euro;
      >
      >How can I check if the problem is on client or server side and locate
      >it?
      >
      If your server returns the string '&euro;', SOAP::Lite should escape
      the & when creating the message and un-escape at the client. Can you
      provide samples of your client and server code?

      Regards
      Duncan



    • Maurice McCabe
      Use it to remove offending characters from data values before inserting into XML doc. Something like this: SOAP::Data- name( Product_Name =
      Message 2 of 7 , Jul 20, 2004
      • 0 Attachment
        Message
        Use it to remove offending characters from data values before inserting into XML doc. Something like this:
         
        SOAP::Data->name("Product_Name" => escape($Product_Name))
        -----Original Message-----
        From: Maurice McCabe [mailto:mmccabe@...]
        Sent: Tuesday, July 20, 2004 3:44 PM
        To: soaplite@yahoogroups.com
        Subject: RE: [soaplite] wrong encoding (perhabs caused by utf8?)

        The XML standard requires that certain characters contained within the XML document content be escaped. Otherwise it is not a legal XML document. I use the following subroutine to do the substitution. It only contains the values I needed to escape. There may be other values not included in my list.
         
        sub escape {
            # must escape certain characters or the XML document is invalid
            my ($str) = @_;
            $str =~ s/</&lt;/g;
            $str =~ s/>/&gt;/g;
            $str =~ s/&/&amp;/g;
            $str =~ s/"/&quote;/g;
            $str =~ s/'/&apos;/g;
         
            # strip out invalid characters (according to Mircosoft)
            #$str =~ s/[:\-\n\r()]//g;

            return $str;
        }
         
        Regards,
         
        Maurice
        -----Original Message-----  
        From: Duncan Cameron [mailto:duncan_cameron2002@...]
        Sent: Tuesday, July 20, 2004 8:33 AM
        To: Marten Lehmann; soaplite@yahoogroups.com
        Subject: Re: [soaplite] wrong encoding (perhabs caused by utf8?)

        At 2004-07-20, 16:22:06 Marten Lehmann <lehmann@...> wrote:

        >Hello,
        >
        >I did some experiments, but I couldn't solve the problem. I installed
        >the latest SOAP-Lite (0.60a) on client and server, but I still get e.g.
        >
        >&amp;euro;
        >
        >instead of &euro;
        >
        >How can I check if the problem is on client or server side and locate
        >it?
        >
        If your server returns the string '&euro;', SOAP::Lite should escape
        the & when creating the message and un-escape at the client. Can you
        provide samples of your client and server code?

        Regards
        Duncan




      • Tim Jenness
        ... The & replacement should happen first, otherwise the & in < will become &lt;. -- Tim Jenness JAC software http://www.jach.hawaii.edu/~timj
        Message 3 of 7 , Jul 20, 2004
        • 0 Attachment
          On Tue, 20 Jul 2004, Maurice McCabe wrote:

          > The XML standard requires that certain characters contained within the
          > XML document content be escaped. Otherwise it is not a legal XML
          > document. I use the following subroutine to do the substitution. It only
          > contains the values I needed to escape. There may be other values not
          > included in my list.
          >
          > sub escape {
          > # must escape certain characters or the XML document is invalid
          > my ($str) = @_;
          > $str =~ s/</</g;
          > $str =~ s/>/>/g;
          > $str =~ s/&/&/g;
          > $str =~ s/"/"e;/g;
          > $str =~ s/'/'/g;

          The & replacement should happen first, otherwise the '&' in < will
          become &lt;.

          --
          Tim Jenness
          JAC software
          http://www.jach.hawaii.edu/~timj
        Your message has been successfully submitted and would be delivered to recipients shortly.