StringUtils isNumeric returns true when input is “???”, why? [duplicate]

醉酒当歌 提交于 2019-12-09 17:51:44

问题


I was reading the commons.apache.org isNumeric method definition and it states:

StringUtils.isNumeric("???") = true;

I am not sure why "???" is considered to be numeric. My guesses are:

  • A "?" is considered a unicode digit
  • It is some kind of regex pattern


回答1:


I was able to find the answer to this question by looking at the StringUtils source code for the isNumeric method. In the source code that line appears as:

StringUtils.isNumeric("\u0967\u0968\u0969")  = true

Where u0967, u0968, u0969 are Devangari Digits one, two, and three respectively. This may be a browser issue causing the characters to not be rendered correctly in the API.




回答2:


Looking at the code, the example is

StringUtils.isNumeric("\u0967\u0968\u0969")  = true

\u0967 is , which is "Devanagari Digit One"

\u0967 is , which is "Devanagari Digit Two"

So they are digits!



来源:https://stackoverflow.com/questions/38577448/stringutils-isnumeric-returns-true-when-input-is-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!