Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag for India asked on

how encode a url in java script

Hi ,

I have pass some japness char throw URL in java script and i get values in java . while i am getting junk value only coming ? how can i get the values  correctly?
JavaScriptJava

Avatar of undefined
Last Comment
Sathish David Kumar N

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Big Monty

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Sathish David Kumar N

ASKER
i got java error

java.io.CharConversionException: isHexDigit like this ?
is there any other way ??
SOLUTION
leakim971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Sathish David Kumar N

ASKER
ya i changed in java script . while i am taking the values in java its giving this error !!

Ya i am using UTF-8 format only .  
leakim971

>Ya i am using UTF-8 format only .

I follow your other thread as you know, we need to be sure of that
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
SOLUTION
cyberhitesh

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Sathish David Kumar N

ASKER
i set some values in popup to parentwindow !!

May be that time char encoding format will change !!

can you tell me how to set the values with UTF-8 format

opener.forName.filedNmae.value="japanesh char";
leakim971

An example :

parent window :


<!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" />
<head>
<title>http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26871660.html</title>
<script>
	function openLittle() {
		little = window.open("little.html");
	}
</script>
</head>
<body>
<form name="forName">
<input name="filedNmae" type="text" value="japanese will appear here" style="width:320px;text-align:center" />
<input type="button" value="click to open popup window" onclick="openLittle();" />
</form>
</body>
</html>

Open in new window

leakim971

little.html :


<!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" />
<head>
<title>http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26871660.html</title>

</head>
<body>
<form name="littleForm">
<input name="japan" type="text" value="put inside japanese chars and click ok to send them to parent" style="width:400px" />
<input type="button" onclick="window.opener.forName.filedNmae.value=document.littleForm.japan.value" value="OK" />
</form>
</body>
</html>

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Sathish David Kumar N

ASKER
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
is this engough ?
leakim971

>is this engough ?  
for two simples HTML pages, yes

...but it seems you get/from data from/to database and so work with server side language
Sathish David Kumar N

ASKER
>>>>>>>>
...but it seems you get/from data from/to database and so work with server side languag
i have set that in java
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
leakim971

ok so if you "put" the value with the wrong format on the server side, you will not get it in the right format on the client side
Sathish David Kumar N

ASKER
actually my problem is

with form submit i can get the values  (Japanese values) so its set proper char-set format

but with out form submitting like pop up window open(i want to retrieve some values so iam going with that url for popup) so that time my char set is not working.
leakim971

"put" mean something like (line 11 of little) :

out.println("<input name=\"japan\" type=\"text\" value=\"" + ImInWrongFormat + "\" style=\"width:400px\" />");

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
leakim971

did you tried my two simple html page ? it work fine on your side?
Sathish David Kumar N

ASKER
Thanks for your time. but iused encodeURI() to solve the issue !!