Deskripsi metode:
Metode ini memungkinkan untuk mengganti querystring.parse
tata bahasa:
Salinan kode adalah sebagai berikut:
querystring.unescape
Menerima parameter:
tidak ada
Kode Sumber:
Salinan kode adalah sebagai berikut:
// Alternatif cepat yang aman untuk decodeuricomponent
QueryString.unescapebuffer = function (s, decodespaces) {
var out = buffer baru (s.length);
var state = 'char'; // menyatakan: char, hex0, hex1
var n, m, hexchar;
untuk (var inIndex = 0, outIndex = 0; inIndex <= s.length; inIndex ++) {
var c = s.charcodeat (inIndex);
switch (state) {
case 'char':
switch (c) {
Case Charcode ('%'):
n = 0;
m = 0;
state = 'hex0';
merusak;
Case Charcode ('+'):
if (decodespaces) c = charcode ('');
// lulus melalui
bawaan:
keluar [outIndex ++] = c;
merusak;
}
merusak;
kasus '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;
} kalau tidak {
out [outIndex ++] = charcode ('%');
keluar [outIndex ++] = c;
state = 'char';
merusak;
}
merusak;
kasus '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;
} kalau tidak {
out [outIndex ++] = charcode ('%');
keluar [outIndex ++] = hexchar;
keluar [outIndex ++] = c;
merusak;
}
out [outIndex ++] = 16 * n+m;
merusak;
}
}
// TODO DUKUNGAN PENGEMBALIAN BUASTRARY.
return out.slice (0, OutIndex - 1);
};