Re: JavaScript & double-byte form input

by "Srinivasan Ramakrishnan" <srinivar(at)md3.vsnl.net.in>

 Date:  Wed, 9 Feb 2000 19:26:17 +0530
 To:  <gray_s(at)tvq.canon.co.jp>,
<hwg-languages(at)hwg.org>
 References:  co
  todo: View Thread, Original
Hi,

If I guessed right, Japanese characters are UNICODE, and the escape() &
unescape() are for ascii, however by adding a \u (I think!, better check it
up) you could convert your URL into UNICODE compliant format.


Cheers,
-Srini

----- Original Message -----
From: <gray_s(at)tvq.canon.co.jp>
To: <hwg-languages(at)hwg.org>
Sent: Wednesday, February 09, 2000 5:31 AM
Subject: JavaScript & double-byte form input


| Hi All,
|
| I have a form that opens up a new window when the submit button is
clicked.
| Form results are then spewed out to the new window.
|
| My problem is that I am working with double-byte characters (Japanese).
| When I enter single-byte (English) input into the form, the script works
| normally.
| However, when I enter double-byte (Japanese) characters, the URL passed to
the
| cgi script is mutated by the JavaScript
| so that the value in the URL is not the same Japanese character as what I
| entered in the form.
|
| My script and the form are as below.
| I think the problem is occuring in one of the two following lines:
|
|                   var entry=document.forms["GetMe"].entry.value;
|                   myUrl =
| '/cgi-bin/jedi/jedi2.pl?language='+language+'&entry='+entry;
|
| 'entry' is the single- or double- byte characters I enter into the form.
| Somehow the value of this variable is mutilated when it is converted into
the
| URL string in the 2nd line above.
|
| Any hints would be greatly appreciated.
|
| Thanks in advance,
|
| Shawn Gray
| s_gray(at)tvq.canon.co.jp
|
|
| <SCRIPT>
|      function returnSelection(radioButton) {
|                var selection=null;
|           for(var i=0; i < radioButton.length; i++) {
|                if(radioButton[i].checked) {
|                     language=radioButton[i].value;
|                     return language;
|                }
|           }
|           return selection;
|      }
|
|      function Jedi (form){
|           returnSelection(document.forms[0].language);
|           var entry=document.forms["GetMe"].entry.value;
|           myUrl =
'/cgi-bin/jedi/jedi2.pl?language='+language+'&entry='+entry;
|           Win1 = open
|
(myUrl,"JediWin","width=350,height=300,scrollbars,location,resizable,status"
);
|           Win1.status = "Here is what JEDI found for you.";
|           window.close();
|      }
| </SCRIPT>
|
|
| <form method="POST" name="GetMe">
|      <INPUT TYPE="RADIO" NAME="language" VALUE="EJ">E to J
|             <INPUT TYPE="RADIO" NAME="language" VALUE="JE" CHECKED>J to
E<BR>
|             Search for: <input type="text" name="entry" size="10"><P>
|             <input type="button" value="Search" name="submit"
| onClick='Jedi(this.form);'>
| </form>
|
|
|
|

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA