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

Character Encoding Problems

Expand Messages
  • jokullaudunsson
    The following is a code snippet used to post a form. The success handler then makes a seperate request with an innerHTML to update the page AJAX style.
    Message 1 of 6 , Mar 3, 2006
    • 0 Attachment
      The following is a code snippet used to post a form. The success
      handler then makes a seperate request with an innerHTML to update the
      page AJAX style.

      YAHOO.util.Connect.setForm(formId);
      var cObj = YAHOO.util.Connect.asyncRequest( 'POST', 'reserve.asp',
      cbNewReserve );

      Everything works wonderfully except for foreign characters when
      submitting forms. I've set all page headers to charset=iso-8859-1.
      This works when retrieving with an asyncRequest but not submitting
      with a form. IOW the stuff going into my db backend is scrambled while
      manually putting it in makes it show up with all foreign characters.

      I've tried various flavors of the following without any luck.

      YAHOO.util.Connect.initHeader('Accept-Charset','ISO-8859-1');

      Any pointers greatly appreciated + huge thanks to the Yahoo UI team.
    • Thomas S. Sha
      ... XHR doesn t observe your header values and forces UTF-8; perhaps this may be affecting your use case? If you post a test case, I d be happy to test on my
      Message 2 of 6 , Mar 3, 2006
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "jokullaudunsson"
        <jokullsolberg@...> wrote:
        >
        > The following is a code snippet used to post a form. The success
        > handler then makes a seperate request with an innerHTML to update the
        > page AJAX style.
        >
        > YAHOO.util.Connect.setForm(formId);
        > var cObj = YAHOO.util.Connect.asyncRequest( 'POST', 'reserve.asp',
        > cbNewReserve );
        >
        > Everything works wonderfully except for foreign characters when
        > submitting forms. I've set all page headers to charset=iso-8859-1.
        > This works when retrieving with an asyncRequest but not submitting
        > with a form. IOW the stuff going into my db backend is scrambled while
        > manually putting it in makes it show up with all foreign characters.
        >
        > I've tried various flavors of the following without any luck.
        >
        > YAHOO.util.Connect.initHeader('Accept-Charset','ISO-8859-1');
        >
        > Any pointers greatly appreciated + huge thanks to the Yahoo UI team.

        XHR doesn't observe your header values and forces UTF-8; perhaps this
        may be affecting your use case? If you post a test case, I'd be happy
        to test on my end as well.

        Regards,
        Thomas
      • Satya Agus Tandinata
        Im not really sure about this (so correct me if i wrong) but POST ing data will bring current Charset encoding of the Page try to check your meta content
        Message 3 of 6 , Mar 3, 2006
        • 0 Attachment
          Im not really sure about this (so correct me if i wrong)
          but POST'ing data will bring current Charset encoding of the Page

          try to check your meta content charset

          "Thomas S. Sha" <tsha@...> wrote:
          --- In ydn-javascript@yahoogroups.com, "jokullaudunsson"
          <jokullsolberg@...> wrote:
          >
          > The following is a code snippet used to post a form. The success
          > handler then makes a seperate request with an innerHTML to update the
          > page AJAX style.
          >
          > YAHOO.util.Connect.setForm(formId);
          > var cObj = YAHOO.util.Connect.asyncRequest( 'POST', 'reserve.asp',
          > cbNewReserve );
          >
          > Everything works wonderfully except for foreign characters when
          > submitting forms. I've set all page headers to charset=iso-8859-1.
          > This works when retrieving with an asyncRequest but not submitting
          > with a form. IOW the stuff going into my db backend is scrambled while
          > manually putting it in makes it show up with all foreign characters.
          >
          > I've tried various flavors of the following without any luck.
          >
          > YAHOO.util.Connect.initHeader('Accept-Charset','ISO-8859-1');
          >
          > Any pointers greatly appreciated + huge thanks to the Yahoo UI team.

          XHR doesn't observe your header values and forces UTF-8; perhaps this
          may be affecting your use case?  If you post a test case, I'd be happy
          to test on my end as well.

          Regards,
          Thomas



          Yahoo! Mail
          Bring photos to life! New PhotoMail makes sharing a breeze.

        • Jökull Sólberg Auðunsson
          ... I converted all documents to UTF-8 - this seems to work fine. Thank you.
          Message 4 of 6 , Mar 3, 2006
          • 0 Attachment
            --- In ydn-javascript@yahoogroups.com, "Thomas S. Sha" <tsha@...> wrote:
            >
            > --- In ydn-javascript@yahoogroups.com, "jokullaudunsson"
            > <jokullsolberg@> wrote:
            > >
            > > The following is a code snippet used to post a form. The success
            > > handler then makes a seperate request with an innerHTML to update the
            > > page AJAX style.
            > >
            > > YAHOO.util.Connect.setForm(formId);
            > > var cObj = YAHOO.util.Connect.asyncRequest( 'POST', 'reserve.asp',
            > > cbNewReserve );
            > >
            > > Everything works wonderfully except for foreign characters when
            > > submitting forms. I've set all page headers to charset=iso-8859-1.
            > > This works when retrieving with an asyncRequest but not submitting
            > > with a form. IOW the stuff going into my db backend is scrambled while
            > > manually putting it in makes it show up with all foreign characters.
            > >
            > > I've tried various flavors of the following without any luck.
            > >
            > > YAHOO.util.Connect.initHeader('Accept-Charset','ISO-8859-1');
            > >
            > > Any pointers greatly appreciated + huge thanks to the Yahoo UI team.
            >
            > XHR doesn't observe your header values and forces UTF-8; perhaps this
            > may be affecting your use case? If you post a test case, I'd be happy
            > to test on my end as well.
            >
            > Regards,
            > Thomas
            >

            I converted all documents to UTF-8 - this seems to work fine. Thank you.
          • Jökull Sólberg Auðunsson
            ... I switched back to ISO-8859-1 since UTF-8 is not suited for SQL storage. I m still baffled by the whole encoding thing - Can I use js encode() function to
            Message 5 of 6 , Mar 3, 2006
            • 0 Attachment
              --- In ydn-javascript@yahoogroups.com, "Thomas S. Sha" <tsha@...> wrote:
              >
              > --- In ydn-javascript@yahoogroups.com, "jokullaudunsson"
              > <jokullsolberg@> wrote:
              > >
              > > The following is a code snippet used to post a form. The success
              > > handler then makes a seperate request with an innerHTML to update the
              > > page AJAX style.
              > >
              > > YAHOO.util.Connect.setForm(formId);
              > > var cObj = YAHOO.util.Connect.asyncRequest( 'POST', 'reserve.asp',
              > > cbNewReserve );
              > >
              > > Everything works wonderfully except for foreign characters when
              > > submitting forms. I've set all page headers to charset=iso-8859-1.
              > > This works when retrieving with an asyncRequest but not submitting
              > > with a form. IOW the stuff going into my db backend is scrambled while
              > > manually putting it in makes it show up with all foreign characters.
              > >
              > > I've tried various flavors of the following without any luck.
              > >
              > > YAHOO.util.Connect.initHeader('Accept-Charset','ISO-8859-1');
              > >
              > > Any pointers greatly appreciated + huge thanks to the Yahoo UI team.
              >
              > XHR doesn't observe your header values and forces UTF-8; perhaps this
              > may be affecting your use case? If you post a test case, I'd be happy
              > to test on my end as well.
              >
              > Regards,
              > Thomas
              >

              I switched back to ISO-8859-1 since UTF-8 is not suited for SQL
              storage. I'm still baffled by the whole encoding thing -
              Can I use js encode() function to pass it on to the server through XHR
              and then use something like urldecode() in ASP? Or better yet, force
              XHR to use ISO-8859-1!

              Thanks in advance
            • Thomas S. Sha
              ... setForm already encodes the POST body, so you should be able to decode it in ASP. You can also test the string yourself by assembling the form
              Message 6 of 6 , Mar 3, 2006
              • 0 Attachment
                --- In ydn-javascript@yahoogroups.com, Jökull Sólberg Auðunsson
                <jokullsolberg@...> wrote:
                > I switched back to ISO-8859-1 since UTF-8 is not suited for SQL
                > storage. I'm still baffled by the whole encoding thing -
                > Can I use js encode() function to pass it on to the server through XHR
                > and then use something like urldecode() in ASP? Or better yet, force
                > XHR to use ISO-8859-1!

                setForm already encodes the POST body, so you should be able to decode
                it in ASP. You can also test the string yourself by assembling the
                form label/values and pass it as an argument to asyncRequest.

                Regards,
                Thomas
              Your message has been successfully submitted and would be delivered to recipients shortly.