How does asp detect the actual length of a string containing a Chinese character
Editor to share with you asp how to detect the actual length of Chinese strings, I believe that most people do not understand, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
In the actual process, we often have to check the actual length of the string containing Chinese characters.
Because Chinese characters, together with English characters. Judge you to be in trouble.
The principle is the same as in asp. Judge one by one. It's Chinese plus 2 English plus 1.
The code is as follows:
ASCIIEncoding n = new ASCIIEncoding (); byte [] b = n.GetBytes (str); int l = 0; / / l is the actual length of the string for (int item0)