3

I am working on a browser plugin that takes the URL of the current page or any selected link as a parameter and send it to our server. When characters of the basic latin alphabet are present in the url (like http://en.wikipedia.org/wiki/Vehicle), the plugin works fine. However, when the URL contains characters from another alphabet such as http://ru.wikipedia.org/wiki/Коляска the plugin does not work, I do use the encodeURIComponentmethod but that does not seem to solve the issue. Any idea?

Thanks,

Olivier.

2
  • 2
    ru.wikipedia.org/wiki/Коляска is not really a valid URL. When you enter that into a modern browser, it will URLEncode the characters automatically. Can you explain in more detail what you are doing, where the data is coming from, and what encodeURIComponent does that doesn't suit? Also, what do you mean by "browser plugin" exactly? Commented Sep 14, 2010 at 19:20
  • 1
    Background: stackoverflow.com/questions/2742852/unicode-characters-in-urls Commented Sep 14, 2010 at 19:21

2 Answers 2

1

You probably want to use encodeURI/decodeURI, if you are trying to take a full URI with non-ASCII characters and translate it into its encoded form. These preserve special URI characters, such as : and /, instead of escaping them; it only escapes non-ASCII characters and characters that are invalid in URIs. Thus, they do essentially the same thing as typing in the address bar or putting a URI in an <a href="..."> (though the behavior might vary somewhat between browser, and isn't exactly the same).

encodeURIComponent is intended for encoding only a single component of a URI, replacing special characters that are meaningful in URIs, so that you can use the component as a query parameter or path component in a longer URI.

Sign up to request clarification or add additional context in comments.

Comments

0

This one says it covers UTF-8. http://www.webtoolkit.info/javascript-url-decode-encode.html. Might solve your problem

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.