C implementation code to determine whether a string is full or half Angle
- 2020-06-07 05:12:04
- OfStack
The full Angle of the C# string is a character represented by 2 bytes
The half Angle of the C# string is 1 character represented by 1 byte
. So we can use string length and System text. Encoding. Default. Judging GetByteCount
Where string. length represents the number of characters in the C# string string,
System. text. Encoding. Default. GetByteCount said the number of bytes of the string.
Half Angle is judged as follows:
if (checkString.Length == Encoding.Default.GetByteCount(checkString))
{
return true;
}
else
{
return false;
}
The full Angle is determined as follows:
if (2 * checkString.Length == Encoding.Default.GetByteCount(checkString))
{
return true;
}
else
{
return false;
}
This achieves the purpose of determining whether the C# string is full Angle or half Angle.