メソッド説明:
この方法により、QueryString.Parseをオーバーライドできます
文法:
コードコピーは次のとおりです。
QueryString.Unescape
パラメーターを受信:
なし
ソースコード:
コードコピーは次のとおりです。
// DeCodeuricomponentに代わる安全な高速
QueryString.unescapeBuffer = function(s、decodespaces){
var out = new Buffer(s.length);
var state = 'char'; //状態:char、hex0、hex1
var n、m、hexchar;
for(var inindex = 0、outindex = 0; inindex <= s.length; inindex ++){
var c = s.charcodeat(inindex);
switch(state){
ケース 'char':
switch(c){
case charcode( '%'):
n = 0;
m = 0;
state = 'hex0';
壊す;
case charcode( '+'):
if(decodespaces)c = charcode( '');
//スルーを渡します
デフォルト:
out [outindex ++] = c;
壊す;
}
壊す;
ケース 'hex0':
state = 'hex1';
hexchar = c;
if(charcode( '0')<= c && c <= charcode( '9')){
n = c -charcode( '0');
} else if(charcode( 'a')<= c && c <= charcode( 'f')){
n = c -charcode( 'a') + 10;
} else if(charcode( 'a')<= c && c <= charcode( 'f')){
n = c -charcode( 'a') + 10;
} それ以外 {
out [outindex ++] = charcode( '%');
out [outindex ++] = c;
state = 'char';
壊す;
}
壊す;
ケース「hex1」:
state = 'char';
if(charcode( '0')<= c && c <= charcode( '9')){
M = C -Charcode( '0');
} else if(charcode( 'a')<= c && c <= charcode( 'f')){
M = C -Charcode( 'A') + 10;
} else if(charcode( 'a')<= c && c <= charcode( 'f')){
M = C -Charcode( 'A') + 10;
} それ以外 {
out [outindex ++] = charcode( '%');
out [outindex ++] = hexchar;
out [outindex ++] = c;
壊す;
}
out [outindex ++] = 16 * n+m;
壊す;
}
}
// TODOサポート任意のバッファーを返します。
return out.slice(0、outindex -1);
};