根据文档 ,字符串'123'是数字。
由于我认为这可能是文档中的错误,我运行测试来验证该语句。 我发现根据Apache Commons它是数字的。
为什么这个String数字? 那些字符代表什么?
According to Apache Commons Lang's documentation for StringUtils.isNumeric(), the String '१२३' is numeric.
Since I believed this might be a mistake in the documentation, I ran tests to verify the statement. I found that according to Apache Commons it is numeric.
Why is this String numeric? What do those characters represent?
最满意答案
因为“CharSequence只包含Unicode数字”(引用链接的文档 )。
Character.isDigit所有字符都返回true:
一些包含数字的Unicode字符范围:
'\ u0030'到'\ u0039',ISO-LATIN-1数字('0'到'9') '\ u0660'到'\ u0669',阿拉伯语 - 印数字 '\ u06F0'到'\ u06F9',扩展阿拉伯语 - 印度数字 '\ u0966'到'\ u096F',梵文数字 '\ uFF10'通过'\ uFF19',全宽数字许多其他字符范围也包含数字。
१२३是梵文数字:
१是DEVANAGARI DIGIT ONE, \u0967 २是DEVANAGARI DIGIT TWO, \u0968 ३是DEVANAGARI DIGIT三, \u0969Because that "CharSequence contains only Unicode digits" (quoting your linked documentation).
All of the characters return true for Character.isDigit:
Some Unicode character ranges that contain digits:
'\u0030' through '\u0039', ISO-LATIN-1 digits ('0' through '9') '\u0660' through '\u0669', Arabic-Indic digits '\u06F0' through '\u06F9', Extended Arabic-Indic digits '\u0966' through '\u096F', Devanagari digits '\uFF10' through '\uFF19', Fullwidth digitsMany other character ranges contain digits as well.
१२३ are Devanagari digits:
१ is DEVANAGARI DIGIT ONE, \u0967 २ is DEVANAGARI DIGIT TWO, \u0968 ३ is DEVANAGARI DIGIT THREE, \u0969更多推荐
发布评论