JavaScript encode cyrillic symbols with encodeURIComponent

JavaScript and Cyrillic

Let’s assume we’ve a JavaScript file which rewrites the location.href, resulting in changes in the URI of the browser. Everything is OK till you work with Latin alphabet. The problem arises when you decide to put some Cyrillic symbols into the string.

The encode() function

With that function you can encode the URL if you have some entity symbols. It is not like but it should be something like encodeURI in PHP. The problem is that this function does not work correctly with Cyrillic symbols.

Use encodeURIComponent

There is another usefull function which does this. It’s called encodeURIComponent, and I strongly recomment its use.

Related posts:

  1. Flex 3 import swf symbols
  2. What make JavaScript closures work?
  3. OOP JavaScript: Accessing Public Methods in Private Methods
This entry was posted in javascript, micro tutorial, web development and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">