mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-03-13 08:40:43 +08:00
Fix: NumberFormatException with non-ASCII Unicode digits in MyAtoi (#7231)
Fix myAtoi handling of non-ASCII Unicode digits
This commit is contained in:
committed by
GitHub
parent
0f9139dc42
commit
a7eeee2b5b
@@ -45,7 +45,9 @@ public final class MyAtoi {
|
||||
int number = 0;
|
||||
while (index < length) {
|
||||
char ch = s.charAt(index);
|
||||
if (!Character.isDigit(ch)) {
|
||||
|
||||
// Accept only ASCII digits
|
||||
if (ch < '0' || ch > '9') {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user