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

Connection Manager and UTF-8 (problem only with IE)

Expand Messages
  • Tom
    hi all, I feel a little bit stupid because I just cannot figure out what causes my problem. so I hope you can help me: my whole website is utf-8 (php-header,
    Message 1 of 7 , Sep 29, 2008
    • 0 Attachment
      hi all,

      I feel a little bit stupid because I just cannot figure out what causes
      my problem. so I hope you can help me:

      my whole website is utf-8 (php-header, meta-tag, files saved as utf-8,
      mysql utf-8).
      I never had a problem with that.
      Now I am using the dialog with two simple fields and want the user
      inputs to be saved in MySQL with the connection manager.

      For now and for debug purposes the php file that is executed via the
      connection manager does only write to a text file (which is also utf-8).
      This works perfect in Firefox.
      In IE (7) I only get ????? (question marks).

      I really hope you can help me here.

      Thanks a lot

      Tom

      Please see my simplified code:

      <?
      header("Content-type: text/html; charset=utf-8");
      ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8"
      />
      <title>Test</title>

      <link rel="stylesheet" type="text/css"
      href="libs/yui/build/container/assets/skins/sam/container.css" />

      <script type="text/javascript"
      src="libs/yui/build/utilities/utilities.js"></script>
      <script type="text/javascript"
      src="libs/yui/build/container/container-min.js"></script>

      <script>

      function init_Dialog() {

      var handleSubmit = function() {
      this.submit();
      };
      var handleCancel = function() {
      this.cancel();
      };
      var handleSuccess = function(o) {
      var response = o.responseText;
      response = response.split("<!")[0];
      };
      var handleFailure = function(o) {
      alert("Submission failed: " + o.status);
      };

      bs_dialog_test = new YAHOO.widget.Dialog("test_dialog",
      { width : "525px",
      fixedcenter : true,
      visible : false,
      modal: true,
      constraintoviewport : true,
      buttons : [ { text:"Save",
      handler:handleSubmit, isDefault:true },
      { text:"Cancel",
      handler:handleCancel } ]
      });

      bs_dialog_test.callback = { success: handleSuccess,
      failure: handleFailure };

      bs_dialog_test.render(document.body);

      }
      YAHOO.util.Event.onDOMReady(init_Dialog);

      function ShowDialog(action) {

      YAHOO.util.Dom.get('test_dialog').style.display = "block";

      bs_dialog_test.validate = function() {

      var data = this.getData();

      if (data.name == "") {
      alert("Please enter a name.");
      return false;
      } else {

      var callback = {
      success : function(o) {
      var response = o.responseText;

      alert('OK');
      },
      failure : function(o) {
      alert('Error 1');
      }
      }

      var request = YAHOO.util.Connect.asyncRequest( 'GET',
      "include/http_requests/conn_test_HTTPRequest.php?action=save_group_gener\
      al_data&groupname=" + data.name + "&groupdescr=" + data.descr + "&r=" +
      new Date().getTime(), callback );

      }
      };

      bs_dialog_test.show();

      }

      </script>
      </head>

      <body class="yui-skin-sam">

      <div class="container">

      <h1>Test</h1>

      <a href="#" onclick="ShowDialog('add');" class="navi2">NEU</a>

      <div id="test_dialog" style="display:none;">
      <div class="hd">Test</div>
      <div class="bd">
      <form action="<? echo $_SERVER["PHP_SELF"] ?>" method="post"
      name="frmTest" accept-charset="utf-8">
      <table width="500" border="0" cellpadding="5" cellspacing="1">
      <tr>
      <td>Name</td>
      <td><input type="text" name="name" value="<? echo
      htmlspecialchars(stripslashes($name)) ?>" style="width:350px;"
      tabindex="1" /></td>
      </tr>
      <tr>
      <td>Beschreibung</td>
      <td><textarea name="descr" rows="4" cols="100"
      style="width:355px;" tabindex="2"><? echo
      htmlspecialchars(stripslashes($descr)) ?></textarea></td>
      </tr>
      </table>
      </form>

      </div>


      </body>
      </html>


      and the "conn_test_HTTPRequest.php":

      <?
      header("Content-type: text/html; charset=utf-8");

      function LogToTempFile($str) {

      $filename = "test_".date("Ymd").".txt";
      $handle=fopen($filename, "a");
      if (!fwrite($handle, $str)) {
      //upps
      }
      fclose($handle);
      }


      while(list($k,$v)=each($_GET)) {
      LogToTempFile($k." xxx ".$v."\n");
      }

      ?>
    • Lucas Smith
      ... include/http_requests/conn_test_HTTPRequest.php?action=save_group_gener ... I was unable to reproduce your issue when testing locally with the content
      Message 2 of 7 , Sep 29, 2008
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "Tom" <tomnyc2004@...> wrote:
        >
        > hi all,
        >
        > I feel a little bit stupid because I just cannot figure out what causes
        > my problem. so I hope you can help me:
        >
        > my whole website is utf-8 (php-header, meta-tag, files saved as utf-8,
        > mysql utf-8).
        > I never had a problem with that.
        > Now I am using the dialog with two simple fields and want the user
        > inputs to be saved in MySQL with the connection manager.
        >
        > For now and for debug purposes the php file that is executed via the
        > connection manager does only write to a text file (which is also utf-8).
        > This works perfect in Firefox.
        > In IE (7) I only get ????? (question marks).
        >
        > I really hope you can help me here.
        >
        > Thanks a lot
        >
        > Tom
        >
        > Please see my simplified code:
        >
        > <?
        > header("Content-type: text/html; charset=utf-8");
        > ?>
        > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        > <html xmlns="http://www.w3.org/1999/xhtml">
        > <head>
        > <meta http-equiv="content-type" content="text/html; charset=utf-8"
        > />
        > <title>Test</title>
        >
        > <link rel="stylesheet" type="text/css"
        > href="libs/yui/build/container/assets/skins/sam/container.css" />
        >
        > <script type="text/javascript"
        > src="libs/yui/build/utilities/utilities.js"></script>
        > <script type="text/javascript"
        > src="libs/yui/build/container/container-min.js"></script>
        >
        > <script>
        >
        > function init_Dialog() {
        >
        > var handleSubmit = function() {
        > this.submit();
        > };
        > var handleCancel = function() {
        > this.cancel();
        > };
        > var handleSuccess = function(o) {
        > var response = o.responseText;
        > response = response.split("<!")[0];
        > };
        > var handleFailure = function(o) {
        > alert("Submission failed: " + o.status);
        > };
        >
        > bs_dialog_test = new YAHOO.widget.Dialog("test_dialog",
        > { width : "525px",
        > fixedcenter : true,
        > visible : false,
        > modal: true,
        > constraintoviewport : true,
        > buttons : [ { text:"Save",
        > handler:handleSubmit, isDefault:true },
        > { text:"Cancel",
        > handler:handleCancel } ]
        > });
        >
        > bs_dialog_test.callback = { success: handleSuccess,
        > failure: handleFailure };
        >
        > bs_dialog_test.render(document.body);
        >
        > }
        > YAHOO.util.Event.onDOMReady(init_Dialog);
        >
        > function ShowDialog(action) {
        >
        > YAHOO.util.Dom.get('test_dialog').style.display = "block";
        >
        > bs_dialog_test.validate = function() {
        >
        > var data = this.getData();
        >
        > if (data.name == "") {
        > alert("Please enter a name.");
        > return false;
        > } else {
        >
        > var callback = {
        > success : function(o) {
        > var response = o.responseText;
        >
        > alert('OK');
        > },
        > failure : function(o) {
        > alert('Error 1');
        > }
        > }
        >
        > var request = YAHOO.util.Connect.asyncRequest( 'GET',
        >
        "include/http_requests/conn_test_HTTPRequest.php?action=save_group_gener\
        > al_data&groupname=" + data.name + "&groupdescr=" + data.descr + "&r=" +
        > new Date().getTime(), callback );
        >
        > }
        > };
        >
        > bs_dialog_test.show();
        >
        > }
        >
        > </script>
        > </head>
        >
        > <body class="yui-skin-sam">
        >
        > <div class="container">
        >
        > <h1>Test</h1>
        >
        > <a href="#" onclick="ShowDialog('add');" class="navi2">NEU</a>
        >
        > <div id="test_dialog" style="display:none;">
        > <div class="hd">Test</div>
        > <div class="bd">
        > <form action="<? echo $_SERVER["PHP_SELF"] ?>" method="post"
        > name="frmTest" accept-charset="utf-8">
        > <table width="500" border="0" cellpadding="5" cellspacing="1">
        > <tr>
        > <td>Name</td>
        > <td><input type="text" name="name" value="<? echo
        > htmlspecialchars(stripslashes($name)) ?>" style="width:350px;"
        > tabindex="1" /></td>
        > </tr>
        > <tr>
        > <td>Beschreibung</td>
        > <td><textarea name="descr" rows="4" cols="100"
        > style="width:355px;" tabindex="2"><? echo
        > htmlspecialchars(stripslashes($descr)) ?></textarea></td>
        > </tr>
        > </table>
        > </form>
        >
        > </div>
        >
        >
        > </body>
        > </html>
        >
        >
        > and the "conn_test_HTTPRequest.php":
        >
        > <?
        > header("Content-type: text/html; charset=utf-8");
        >
        > function LogToTempFile($str) {
        >
        > $filename = "test_".date("Ymd").".txt";
        > $handle=fopen($filename, "a");
        > if (!fwrite($handle, $str)) {
        > //upps
        > }
        > fclose($handle);
        > }
        >
        >
        > while(list($k,$v)=each($_GET)) {
        > LogToTempFile($k." xxx ".$v."\n");
        > }
        >
        > ?>
        >

        I was unable to reproduce your issue when testing locally with the
        content you supplied. You're missing two </div>s and the link default
        action is not prevented, btw.

        What values are you passing to the form?

        Luke
      • Tom
        You are right. I guess the two divs got lost when I simplified my code. I am actually not sure if the way I am dividing the yui dialog example into two
        Message 3 of 7 , Sep 29, 2008
        • 0 Attachment
          You are right. I guess the two "divs" got lost when I simplified my code.
          I am actually not sure if the way I am dividing the yui dialog example
          into two functions is correct: what I am doing is having one
          init-function and then extracting the form validate function and the
          dialog.show() into another function since later on I want to call this
          second function (ShowDialog) and provide it with an id that has an
          impact on the form validate function.

          If I understand your question "What values are you passing to the
          form?" right ... all i do is switching the windows default input
          language to chinese and type chinese characters (whatever they mean)
          into the form and click submit.


          --- In ydn-javascript@yahoogroups.com, "Lucas Smith" <lsmith@...> wrote:
          >
          > --- In ydn-javascript@yahoogroups.com, "Tom" <tomnyc2004@> wrote:
          > >
          > > hi all,
          > >
          > > I feel a little bit stupid because I just cannot figure out what
          causes
          > > my problem. so I hope you can help me:
          > >
          > > my whole website is utf-8 (php-header, meta-tag, files saved as utf-8,
          > > mysql utf-8).
          > > I never had a problem with that.
          > > Now I am using the dialog with two simple fields and want the user
          > > inputs to be saved in MySQL with the connection manager.
          > >
          > > For now and for debug purposes the php file that is executed via the
          > > connection manager does only write to a text file (which is also
          utf-8).
          > > This works perfect in Firefox.
          > > In IE (7) I only get ????? (question marks).
          > >
          > > I really hope you can help me here.
          > >
          > > Thanks a lot
          > >
          > > Tom
          > >
          > > Please see my simplified code:
          > >
          > > <?
          > > header("Content-type: text/html; charset=utf-8");
          > > ?>
          > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          > > <html xmlns="http://www.w3.org/1999/xhtml">
          > > <head>
          > > <meta http-equiv="content-type" content="text/html;
          charset=utf-8"
          > > />
          > > <title>Test</title>
          > >
          > > <link rel="stylesheet" type="text/css"
          > > href="libs/yui/build/container/assets/skins/sam/container.css" />
          > >
          > > <script type="text/javascript"
          > > src="libs/yui/build/utilities/utilities.js"></script>
          > > <script type="text/javascript"
          > > src="libs/yui/build/container/container-min.js"></script>
          > >
          > > <script>
          > >
          > > function init_Dialog() {
          > >
          > > var handleSubmit = function() {
          > > this.submit();
          > > };
          > > var handleCancel = function() {
          > > this.cancel();
          > > };
          > > var handleSuccess = function(o) {
          > > var response = o.responseText;
          > > response = response.split("<!")[0];
          > > };
          > > var handleFailure = function(o) {
          > > alert("Submission failed: " + o.status);
          > > };
          > >
          > > bs_dialog_test = new YAHOO.widget.Dialog("test_dialog",
          > > { width : "525px",
          > > fixedcenter : true,
          > > visible : false,
          > > modal: true,
          > > constraintoviewport : true,
          > > buttons : [ { text:"Save",
          > > handler:handleSubmit, isDefault:true },
          > > { text:"Cancel",
          > > handler:handleCancel } ]
          > > });
          > >
          > > bs_dialog_test.callback = { success: handleSuccess,
          > > failure: handleFailure };
          > >
          > > bs_dialog_test.render(document.body);
          > >
          > > }
          > > YAHOO.util.Event.onDOMReady(init_Dialog);
          > >
          > > function ShowDialog(action) {
          > >
          > > YAHOO.util.Dom.get('test_dialog').style.display = "block";
          > >
          > > bs_dialog_test.validate = function() {
          > >
          > > var data = this.getData();
          > >
          > > if (data.name == "") {
          > > alert("Please enter a name.");
          > > return false;
          > > } else {
          > >
          > > var callback = {
          > > success : function(o) {
          > > var response = o.responseText;
          > >
          > > alert('OK');
          > > },
          > > failure : function(o) {
          > > alert('Error 1');
          > > }
          > > }
          > >
          > > var request = YAHOO.util.Connect.asyncRequest( 'GET',
          > >
          >
          "include/http_requests/conn_test_HTTPRequest.php?action=save_group_gener\
          > > al_data&groupname=" + data.name + "&groupdescr=" + data.descr +
          "&r=" +
          > > new Date().getTime(), callback );
          > >
          > > }
          > > };
          > >
          > > bs_dialog_test.show();
          > >
          > > }
          > >
          > > </script>
          > > </head>
          > >
          > > <body class="yui-skin-sam">
          > >
          > > <div class="container">
          > >
          > > <h1>Test</h1>
          > >
          > > <a href="#" onclick="ShowDialog('add');" class="navi2">NEU</a>
          > >
          > > <div id="test_dialog" style="display:none;">
          > > <div class="hd">Test</div>
          > > <div class="bd">
          > > <form action="<? echo $_SERVER["PHP_SELF"] ?>" method="post"
          > > name="frmTest" accept-charset="utf-8">
          > > <table width="500" border="0" cellpadding="5"
          cellspacing="1">
          > > <tr>
          > > <td>Name</td>
          > > <td><input type="text" name="name" value="<? echo
          > > htmlspecialchars(stripslashes($name)) ?>" style="width:350px;"
          > > tabindex="1" /></td>
          > > </tr>
          > > <tr>
          > > <td>Beschreibung</td>
          > > <td><textarea name="descr" rows="4" cols="100"
          > > style="width:355px;" tabindex="2"><? echo
          > > htmlspecialchars(stripslashes($descr)) ?></textarea></td>
          > > </tr>
          > > </table>
          > > </form>
          > >
          > > </div>
          > >
          > >
          > > </body>
          > > </html>
          > >
          > >
          > > and the "conn_test_HTTPRequest.php":
          > >
          > > <?
          > > header("Content-type: text/html; charset=utf-8");
          > >
          > > function LogToTempFile($str) {
          > >
          > > $filename = "test_".date("Ymd").".txt";
          > > $handle=fopen($filename, "a");
          > > if (!fwrite($handle, $str)) {
          > > //upps
          > > }
          > > fclose($handle);
          > > }
          > >
          > >
          > > while(list($k,$v)=each($_GET)) {
          > > LogToTempFile($k." xxx ".$v."\n");
          > > }
          > >
          > > ?>
          > >
          >
          > I was unable to reproduce your issue when testing locally with the
          > content you supplied. You're missing two </div>s and the link default
          > action is not prevented, btw.
          >
          > What values are you passing to the form?
          >
          > Luke
          >
        • Lucas Smith
          ... code. ... [snip] Ok, I m able to reproduce your ???? case. Unfortunately, I m not sure what could be the cause of it, but I m asking around. Luke
          Message 4 of 7 , Oct 1, 2008
          • 0 Attachment
            --- In ydn-javascript@yahoogroups.com, "Tom" <tomnyc2004@...> wrote:
            >
            > You are right. I guess the two "divs" got lost when I simplified my
            code.
            > I am actually not sure if the way I am dividing the yui dialog example
            > into two functions is correct: what I am doing is having one
            > init-function and then extracting the form validate function and the
            > dialog.show() into another function since later on I want to call this
            > second function (ShowDialog) and provide it with an id that has an
            > impact on the form validate function.
            >
            > If I understand your question "What values are you passing to the
            > form?" right ... all i do is switching the windows default input
            > language to chinese and type chinese characters (whatever they mean)
            > into the form and click submit.
            >
            >
            [snip]

            Ok, I'm able to reproduce your ???? case. Unfortunately, I'm not sure
            what could be the cause of it, but I'm asking around.

            Luke
          • tssha
            ... Add the following code before the asyncRequest() call: YAHOO.util.Connect._default_post_header = application/x-www-form-urlencoded; charset=UTF-8
            Message 5 of 7 , Oct 1, 2008
            • 0 Attachment
              --- In ydn-javascript@yahoogroups.com, "Tom" <tomnyc2004@...> wrote:
              >
              > hi all,
              >
              > I feel a little bit stupid because I just cannot figure out what causes
              > my problem. so I hope you can help me:
              >
              > my whole website is utf-8 (php-header, meta-tag, files saved as utf-8,
              > mysql utf-8).
              > I never had a problem with that.
              > Now I am using the dialog with two simple fields and want the user
              > inputs to be saved in MySQL with the connection manager.
              >
              > For now and for debug purposes the php file that is executed via the
              > connection manager does only write to a text file (which is also utf-8).
              > This works perfect in Firefox.
              > In IE (7) I only get ????? (question marks).
              >
              > I really hope you can help me here.

              <snip>

              Add the following code before the asyncRequest() call:

              YAHOO.util.Connect._default_post_header =
              "application/x-www-form-urlencoded; charset=UTF-8"
              // All subsequent asyncRequest() calls to follow.

              What do you see in your file, now, when using IE? The expected
              characters or rubbish, still?

              Regards,
              Thomas
            • tssha
              ... causes ... utf-8). ... Actually, strike the previous suggestion. I wrongly assumed you were using the Dialog s form submission routine. In looking at the
              Message 6 of 7 , Oct 1, 2008
              • 0 Attachment
                --- In ydn-javascript@yahoogroups.com, "tssha" <tsha@...> wrote:
                >
                > --- In ydn-javascript@yahoogroups.com, "Tom" <tomnyc2004@> wrote:
                > >
                > > hi all,
                > >
                > > I feel a little bit stupid because I just cannot figure out what
                causes
                > > my problem. so I hope you can help me:
                > >
                > > my whole website is utf-8 (php-header, meta-tag, files saved as utf-8,
                > > mysql utf-8).
                > > I never had a problem with that.
                > > Now I am using the dialog with two simple fields and want the user
                > > inputs to be saved in MySQL with the connection manager.
                > >
                > > For now and for debug purposes the php file that is executed via the
                > > connection manager does only write to a text file (which is also
                utf-8).
                > > This works perfect in Firefox.
                > > In IE (7) I only get ????? (question marks).
                > >
                > > I really hope you can help me here.
                >
                > <snip>
                >
                > Add the following code before the asyncRequest() call:
                >
                > YAHOO.util.Connect._default_post_header =
                > "application/x-www-form-urlencoded; charset=UTF-8"
                > // All subsequent asyncRequest() calls to follow.
                >
                > What do you see in your file, now, when using IE? The expected
                > characters or rubbish, still?

                Actually, strike the previous suggestion. I wrongly assumed you were
                using the Dialog's form submission routine.

                In looking at the URI, you are retrieving the values from Dialog's
                getData. However, I do not see any encoding operation performed on
                the data before it is sent. Try performing encodeURIComponent() on
                data.name and data.descr in the querystring. Any special characters
                in these fields will be safely expressed as %## before being sent to PHP.

                Regards,
                Thomas
              • Tom
                I am sorry. I was away for some days. I think the encodeURIComponent did it though I was sure that I tried that before. But great, thanks a lot!!!! ...
                Message 7 of 7 , Oct 6, 2008
                • 0 Attachment
                  I am sorry.
                  I was away for some days.

                  I think the "encodeURIComponent" did it though I was sure that I tried
                  that before.

                  But great, thanks a lot!!!!


                  --- In ydn-javascript@yahoogroups.com, "tssha" <tsha@...> wrote:
                  >
                  > --- In ydn-javascript@yahoogroups.com, "tssha" <tsha@> wrote:
                  > >
                  > > --- In ydn-javascript@yahoogroups.com, "Tom" <tomnyc2004@> wrote:
                  > > >
                  > > > hi all,
                  > > >
                  > > > I feel a little bit stupid because I just cannot figure out what
                  > causes
                  > > > my problem. so I hope you can help me:
                  > > >
                  > > > my whole website is utf-8 (php-header, meta-tag, files saved as
                  utf-8,
                  > > > mysql utf-8).
                  > > > I never had a problem with that.
                  > > > Now I am using the dialog with two simple fields and want the user
                  > > > inputs to be saved in MySQL with the connection manager.
                  > > >
                  > > > For now and for debug purposes the php file that is executed via the
                  > > > connection manager does only write to a text file (which is also
                  > utf-8).
                  > > > This works perfect in Firefox.
                  > > > In IE (7) I only get ????? (question marks).
                  > > >
                  > > > I really hope you can help me here.
                  > >
                  > > <snip>
                  > >
                  > > Add the following code before the asyncRequest() call:
                  > >
                  > > YAHOO.util.Connect._default_post_header =
                  > > "application/x-www-form-urlencoded; charset=UTF-8"
                  > > // All subsequent asyncRequest() calls to follow.
                  > >
                  > > What do you see in your file, now, when using IE? The expected
                  > > characters or rubbish, still?
                  >
                  > Actually, strike the previous suggestion. I wrongly assumed you were
                  > using the Dialog's form submission routine.
                  >
                  > In looking at the URI, you are retrieving the values from Dialog's
                  > getData. However, I do not see any encoding operation performed on
                  > the data before it is sent. Try performing encodeURIComponent() on
                  > data.name and data.descr in the querystring. Any special characters
                  > in these fields will be safely expressed as %## before being sent to
                  PHP.
                  >
                  > Regards,
                  > Thomas
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.