Non-latin characters in the url and ajax problems

These troubles have some history for me. In a month a go I experienced problems with calling ajax scripts with url holding utf8 characters – bulgarian alphabet for example. So I wrote a javascript function which actually was a bit messy that could handle the problem using encodeURIComponent. Afterwards I found that I simply could use urlencode in php which was a better choice according to me at that time. It looked far more clear to me, so I rewrote the functionality. Guess what – IE 6 problems. No matter that in the output of the javascript function encodeURIComponent and the php function urlencode seemed to be the same! So I had to revert back the functionality and thought to improve my javascript function and will just share that to you as it seems to be a very generic solution that will work with any url … Here it goes:

function encodeCyrillicURIComponent(str)
	str = str.replace(
		new RegExp( "[^a-zA-Z\/-:_]", "g" ),
			return encodeURIComponent($0);

	return str;

This post is also available in: Bulgarian

  1. Use jQuery and forget for your troubles!

    Keyword hint: jquery ajax post/get object

  2. We are talking about the url address, not the passed variables :)

  3. I accept the presentation of next week , for such information , I am in attendance .

  4. Great are those from you . I accept the above-mentioned arrest of your presence , You are wonderful too .

  5. What maxim and methods compliment , compliment , you say it is you what you came here I am . I have admitted that esoteric a lot of things your items .

  6. This means that, unlike with other networks that use a dedicated app, you can just make a call or text like you normally would. Having to use an app requires people to change their habits, so users welcome a service that doesn’t interrupt that.

  7. This order is permitted to stand, it will only be a matter of days before some other prosecutor, insome other important case, before some other judge, seeks a similar order using this case as precedent.

  1. No trackbacks yet.