For instance, I enter Chinese character:[B]路[/B] in google search then i will see one of it parameter with the url like this:
[B]q=%E8%B7%AF[/B]
which is i guess is utf-8 based 16.
any anyone know any javascript can convert [B]路 -> %E8%B7%AF[/B] and when this parameter pass to the other page, the page will decode the [B]%E8%B7%AF -> 路[/B] and redisplay on the textbox filed again. Any idea on this? Pls help, Thanks !
Thanks & Regards, Plant more tree Cut carbon usage
@Orc_ScorcherOct 30.2006 — #Just tried that page, it works for me? Which browser are you using?
Just one thing: as the name suggests encodeURIComponent encode [b]components[/b], not complete URIs. You'd have to write something like uri = "http://yoursite.com/yourpage.html?" + encodeURIComponent(theText)
@Orc_ScorcherOct 30.2006 — #Seems I found the reason: it depends on the character encoding of the page. Go to that w3schools page and before you press the "Edit the text and click me" button, set the character encoding to UTF-8, then you'll get the desired result.
Yes after changing to Character Encoding->UTF-8, it display correctly. But the problem is not every user in the world know they need to set this encoding in their browser. If the user don't change to UTF-8 in their browser, my server side will definitely get wrong information. Anyway the solve this issue?
@Orc_ScorcherOct 30.2006 — #On your own pages that shouldn't be a problem. Configure your server to send your pages with 'Content-Type: text/html; charset=utf-8'. If you can't do that for some reason, include the equivalent '<meta http-equiv="Content-Type" content="text/html; charset=utf-8'">' in the header of your pages.
I was trying to ask around but just couldn't get any answer and I really hope that you can help me here. Actually I am using servlet. When the user enter a Chinese character say 路 in a text field, and I use encodeURIComponent("路") and get %E8%B7%AF then pass it as a parameter to next page. The next page will get this parameter once it load and pass it to servlet. Hence in the servlet, how can I convert it back to 路 or unicode from %E8%B7%AF then pass it to database to search?