MS 实现的 code
public static bool IsDigit(char c) { if (!IsLatin1(c)) { return (CharUnicodeInfo.GetUnicodeCategory(c) == UnicodeCategory.DecimalDigitNumber); } return ((c >= '0') && (c <= '9')); }
public static bool IsNumber(char c) { if (!IsLatin1(c)) { return CheckNumber(CharUnicodeInfo.GetUnicodeCategory(c)); } if (!IsAscii(c)) { return CheckNumber(GetLatin1UnicodeCategory(c)); } return ((c >= '0') && (c <= '9')); } 从上面MS实现的code看, 已经很明显了。 IsNumber 多了一步验证Ascii 码, IsAscii |
IsDigit: {是否是个十进制数字; 范围 0..9}
IsNumber: {是否是个数字符号; 范围包括 0..9, 还有 ASCII 码中的 178、179、185、188、189、190 等}
if you input ¼, ½,¾,²,³,¹ , then IsNumber return true. IsDigit return false.
ASCII |
| HTML | HTML |
| |
Dec | Hex | Symbol | Number | Name | |
176 | B0 | ° | ° | ° |