私は Greasemonkey スクリプトを書いています。2 つの文字列を比較する必要があり、そのうちの 1 つが に等しくなりdocument.location.href
ます。
document.location.href
が等しい場合"http://lema.rae.es/drae/?val=ñáñara"
、何か特別なことをする必要がありますが、document.location.href
別の文字セットに変換されるため、2 つの文字列が等しいかどうかを判断できません。これは例です:
var currentLocation = document.location.href.toString();
var targetLocation = 'http://lema.rae.es/drae/?val=ñáñara';
alert(currentLocation + '\n' + targetLocation);
/* OUTPUT:
http://lema.rae.es/drae/?val=%C3%B1%C3%A1%C3%B1ara
http://lema.rae.es/drae/?val=ñáñara
*/
2 つの文字列を同じ文字セットに変換するにはどうすればよいですか?