Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

isNumeric Method Definition

like image 633
dspano Avatar asked Jul 25 '16 21:07

dspano


People also ask

What is StringUtils isNumeric for?

isNumeric() is a static method of the StringUtils that is used to check if the given string contains only Unicode digits. Unicode symbols other than Unicode digits are not allowed in the string.

What is Java StringUtils?

The StringUtils class defines certain words related to String handling. null - null. empty - a zero-length string ( "" ) space - the space character ( ' ' , char 32) whitespace - the characters defined by Character.isWhitespace(char)


2 Answers

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.

like image 157
dspano Avatar answered Sep 25 '22 10:09

dspano


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!

like image 37
Jean Logeart Avatar answered Sep 24 '22 10:09

Jean Logeart