为什么是'123'数字?(Why does Apache Commons consider '१२३' numeric?)

编程入门 行业动态 更新时间:2024-10-24 04:40:18
为什么是'123'数字?(Why does Apache Commons consider '१२३' numeric?)

根据文档 ,字符串'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三, \u0969

Because 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 digits

Many 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

更多推荐

本文发布于:2023-08-04 23:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1424502.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数字   为什么是   numeric   Apache   Commons

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!