Convert URL parameters to UTF-8 encoding?


I need some help to encode a url from Chinese characters to one which is universal.
As an example the URL would be: CHARACTERS HERE 001.JPG

It wont allow me to post the exact url here beacuse the Chinese characters arent recognized but you should get the idea

This script here:
Is nearly perfect:

when you enter: CHARACTERS HERE 001.JPG
it returns:

However the code on this script relies on an external .js file and i need it all in one document, e.g. using javascript tags in the header
<script type="text/javascript">

Also this script converts the "http://" to "http%3A//" which is not correct...

So can some kind person please post a full code example of how i convert the external .js file to be in the html header between the javascript tags and add in some code to stop the http at the beginning being converted.

Many thanks in advance.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can have the external .js in the same code. Open the .js and copy the code inside the curreent page. Without the .js code I cannot help you.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The answer is so much simpler that it looks. There is already a Javascript function that does de job for you, although it converts the ":" to "%3A, but you can convert it back by replacing it inside the original string:
<script language="javascript">
function URLcode(str){
for testing purposes:
alert(URLcode("!#*=Hello Everybody"));

And, UTF-8 is a way of coding a Unicode Wide character. URLEncode is a way to encode a byte in a hexadecimal manner. UTF-8 and URL coding are not the same from far.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.