When I use escape/encodeURI/encodeURIComponent to encode URI,
it's encoding special characters (like "? [ ] &" ), and all non-ASCII characters.
I prefer the link to look like:
http:/site.com/?tm=ДОБРОЕ**%20**УТРО
instead:
http:/site.com/?tm=%u0414%u041E%u0411%u0420%u041E%u0415**%20**%u0423%u0422%u0420%u041E
My questions:
- Is there any need to encode non-ASCII ?
- Is there any function that encode only special characters ? (without non-ASCII)
escape
to encode to percent encoding. PreferencodeURIComponent
. This way your URI will behttp://example.com/?tm=%D0%94%D0%9E%D0%91%D0%A0%D0%9E%D0%95**%20**%D0%A3%D0%A2%D0%A0%D0%9E
and most browsers will display correctly the unicode characters in the address bar and href tooltips. (SO might encode itself some chars.. jsfiddle.net/bro8Lhza) – Kaiido