目前我被迫使用PHP urlEncode
Javascript
字符串模拟utf-8
var s = "%FNuserMsgToEnc%";
function urlencode(str) {
str = (str + '').toString();
return encodeURIComponent(str)
.replace(/!/g, '\%21')
.replace(/'/g, '\%27')
.replace(/\(/g, '\%28')
.replace(/\)/g, '\%29')
.replace(/\*/g, '\%2A')
.replace(/\%20/g, '+')
.replace(/~/g, '\%7E')
.replace(/Ñ/g, '\%C3%91')
.replace(/ñ/g, '\%C3%B1');
}
WScript.Echo(urlencode(s));
但是脚本不能用最后一行来运行,因为它说语法错误
.replace(/Ñ/g, '\%C3%91')
.replace(/ñ/g, '\%C3%B1');
我想将ñ Ñ ü Ü "
包含在utf-8
字符串中,我该怎么办?
感谢先进。