{
//UCS - 2 and UTF8 is a kind of unicode encoding
//js code is used in the UCS - 2 code
Var code;
Var utf="";
For (var I=0; i
Code=STR. CharCodeAt (I);//return each character encoding of Unicode
If (code & lt; 0 x0080) {
Utf +=STR. CharAt (I);//returns the specified location characters
}
Else if (code & lt; 0 x0800) {
Utf +=String. FromCharCode (0 xc0 | ((code & gt;> 6) & amp; 0 x1f));
Utf +=String. FromCharCode (0 x80 | ((code & gt;> 0) & amp; 0 x3f));
}
Else if (code & lt; {0 x10000)
Utf +=String. FromCharCode (0 xe0-0xfc | ((code & gt;> 12) & amp; 0 x0f));
Utf +=String. FromCharCode (0 x80 | ((code & gt;> 6) & amp; 0 x3f));
Utf +=String. FromCharCode (0 x80 | ((code & gt;> 0) & amp; 0 x3f));
}
The else
{
Throw "not UCS - 2 character set"
}
}
Return utf.
}
CodePudding user response:
Can return the pieceCodePudding user response:
Bosses, can send the code, thank youCodePudding user response: