Swedish characters åäö not replaced correctly with urlencode()
Snorvarg opened this issue · 2 comments
Snorvarg commented
Hi,
I am using your urlencode-function, but found it did not handle Swedish characters åäö correctly.
My workaround was simple:
// åäö is not replaced correctly. 'å' for example, encodeURIComponent() produce "%C3%A5", while php's urldecode() expects "%25C3%25A5".
str = str.replace(/å/g, "%25C3%25A5");
str = str.replace(/ä/g, "%25C3%25A4");
str = str.replace(/ö/g, "%25C3%25B6");
oskarlh commented
"%C3%A5" for "å" is correct. "%25C3%25A5" would be double-encoded ("%25" is the sequence for the percentage sign "%"). Were you calling urldecode twice or something?
Snorvarg commented
Interesting thought! It was many years ago and I had a database with things other people had been working with, so it is probably as you say, I was decoding twice.