Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Apache Commons consider '१२३' numeric?

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?

like image 869
Hannes Avatar asked Oct 20 '16 07:10

Hannes


People also ask

What is the use of Apache Commons?

The Apache Commons is a project of the Apache Software Foundation, formerly under the Jakarta Project. The purpose of the Commons is to provide reusable, open source Java software. The Commons is composed of three parts: proper, sandbox, and dormant.

How do you check if a digit is present in a number Java?

This approach use of String. indexOf() function to check if the character is present in the string or not.

How do you check if a string contains a number Java?

To find whether a given string contains a number, convert it to a character array and find whether each character in the array is a digit using the isDigit() method of the Character class.


1 Answers

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
like image 101
Andy Turner Avatar answered Oct 03 '22 06:10

Andy Turner