Skip to content

Commit 803cdd5

Browse files
authored
Use Locale.ROOT with toUpper to avoid ambiguities
While technically this might not be needed in this specific case, it is a good practice to be explicit about the locale.
1 parent 85053db commit 803cdd5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

java/com/google/openlocationcode/OpenLocationCode.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.google.openlocationcode;
1616

1717
import java.math.BigDecimal;
18+
import java.util.Locale;
1819

1920
/**
2021
* Convert locations to and from convenient short codes.
@@ -153,7 +154,7 @@ public double getEastLongitude() {
153154
* @constructor
154155
*/
155156
public OpenLocationCode(String code) throws IllegalArgumentException {
156-
String newCode = code.toUpperCase();
157+
String newCode = code.toUpperCase(Locale.ROOT);
157158
if (!isValidCode(newCode)) {
158159
throw new IllegalArgumentException(
159160
"The provided code '" + code + "' is not a valid Open Location Code.");
@@ -497,7 +498,7 @@ public static boolean isValidCode(String code) {
497498
if (code == null || code.length() < 2) {
498499
return false;
499500
}
500-
code = code.toUpperCase();
501+
code = code.toUpperCase(Locale.ROOT);
501502

502503
// There must be exactly one separator.
503504
int separatorPosition = code.indexOf(SEPARATOR);

0 commit comments

Comments
 (0)