I haven't had a blog for half a month. I am busy with my work. Thank you for your attention.
There are two things to do today. The first is to announce the answer to the last "interesting mind-reading.
The second is to paste two functions used in the work to calculate the number of bytes of the half-width/full-width string.
(1) answer to "interesting mind reader:
Original post address: Interesting reading
Assuming that the number you selected is XY, the final result is 10 * X + Y-(x + y) = 9 * X, that is, no matter you choose, the final result must be a multiple of 9, that is, one of 9,18, 27,36, 45,54, 63,72, 81. Every time you click, the image corresponding to each number changes once. This gives you an illusion that the answer is not certain, but the image corresponding to the number changes no matter what, 9, 18, the images corresponding to 27,36, 45,54, 63,72, and 81 are the same. So of course it is what you think, because no matter how many XY you choose, it will be the answer.
(2) Calculate the byte count of the halfwidth/fullwidth string
Method 1:
String. Prototype. bytes = function (){
VaR Carr = This. Match (/[^/x00-/xFF]/ig );
Return this. Length + (CARR = NULL? 0: Carr. Length );
}
// Call
// The maximum number of incoming Force grids is 255.
VaR comment = Document. getelementbyid ("delicomment ");
If (comment. value. bytes ()> 255 ){
Alert. ');
Comment. Focus ();
Return;
}
Bytes -----------------------------------------------------------------------------------------------------
Method 2:
Function strlen_all (STR ){
VaR Len = 0;
For (VAR I = 0; I <Str. length; I ++ ){
If (Str. charcodeat (I)> 255)
Len + = 2;
Else
Len ++;
}
Return Len;
}