Home > front end >  Qrcode. Js can't parse text, search the code should be placed where, for the great spirit of ne
Qrcode. Js can't parse text, search the code should be placed where, for the great spirit of ne

Time:11-02

The function str2utf8 (STR)
{
//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 piece

CodePudding user response:

Bosses, can send the code, thank you

CodePudding user response:

reference 1/f, the lakers' championship reply:
return that can block

Bosses can find how to add, I can now parse alphanumeric
  • Related