I'm trying to validate a string to put inside an url as a site's subdirectory, the problem is that my encodeURI() function leaves most of my special characters as they're and I really can't get why since I tried using the same function on W3School code editor and it works just fine.
Let's say I do a test and put a random string into the function
var string = encodeURI("àèìòù°*;£$#"); //these are some of the special characters that the encoding doesn't work on
console.log(string);
the output I get is the string "àèìòù°*;£$#"
as it is,
yet on the W3School console the output is "%C3%A0%C3%A8%C3%AC%C3%B2%C3%B9%C2%B0*;%C2%A3$#"
What's the problem with my function?
p.s. I tried to use encodeURIComponent() too, which I don't know if is more appropriate to use in my case and I noticed it works a bit differently but still gives me the same results
!!EDIT!!
I just found something really unusual in my code and I have less of a clue that I had before on what's happening:
var stringTest = encodeURI("àèìòù°");
console.log(stringTest);
//outputs: %C3%A0%C3%A8%C3%AC%C3%B2%C3%B9%C2%B0
$scope.myDictionary["randomkey"] = stringTest;
//gets "àèìòù°" as the value of stringTest