The querystring. unescape method in node. js is described as follows:

Source: Internet
Author: User

The querystring. unescape method in node. js is described as follows:

Method description:

This method can be used to override querystring. parse.

Syntax:

Copy codeThe Code is as follows:
Querystring. unescape

Receiving parameters:

None

Source code:

Copy codeThe Code is as follows:
// A safe fast alternative to decodeURIComponent
QueryString. unescapeBuffer = function (s, decodeSpaces ){
Var out = new Buffer (s. length );
Var state = 'Char '; // states: CHAR, HEX0, HEX1
Var n, m, hexchar;
For (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 = 'h0 ';
Break;
Case charCode ('+ '):
If (decodeSpaces) c = charCode ('');
// Pass thru
Default:
Out [outIndex ++] = c;
Break;
}
Break;
Case '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;
} Else {
Out [outIndex ++] = charCode ('% ');
Out [outIndex ++] = c;
State = 'Char ';
Break;
}
Break;
Case '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;
} Else {
Out [outIndex ++] = charCode ('% ');
Out [outIndex ++] = hexchar;
Out [outIndex ++] = c;
Break;
}
Out [outIndex ++] = 16 * n + m;
Break;
}
}
// TODO support returning arbitrary buffers.
Return out. slice (0, outIndex-1 );
};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.