Get the App
SLTechnology News&Howtos  ›  Development  › 

How does asp detect the actual length of a string containing a Chinese character

Shulou Source: shulou.com Published: 2022-06-03 12:35:48 10月01日 Update

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)

Tags: Characters actual Chinese string length detection article content English not much code principle most more knowledge symbols industry information information channels process Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Information NVidia MySQL Apple