diff --git a/src/me/teridax/jcash/decode/StringDecoder.java b/src/me/teridax/jcash/decode/StringDecoder.java index c632dc8..86b7cd3 100644 --- a/src/me/teridax/jcash/decode/StringDecoder.java +++ b/src/me/teridax/jcash/decode/StringDecoder.java @@ -56,8 +56,11 @@ public class StringDecoder { public static double decodeCurrency(String currency) throws IllegalArgumentException, NullPointerException { Objects.requireNonNull(currency); + // trim and cut out weird leading single quotes for numbers + var preparedUID = currency.trim().replaceAll("^\\s*['‘`](?=\\d)", ""); + try { - return LOCAL_NUMBER_FORMAT.parse(currency.trim()).doubleValue(); + return LOCAL_NUMBER_FORMAT.parse(preparedUID).doubleValue(); } catch (ParseException ex) { throw new IllegalArgumentException("Not a valid currency in german locale: " + currency, ex); } @@ -74,10 +77,13 @@ public class StringDecoder { public static int decodeUniqueIdentificationNumber(String number) throws IllegalArgumentException, NullPointerException { Objects.requireNonNull(number); + // trim and cut out weird leading single quotes for numbers + var preparedUID = number.trim().replaceAll("^\\s*['‘`](?=\\d)", ""); + // check if the string is a valid unsigned number try { LOCAL_NUMBER_FORMAT.setParseIntegerOnly(true); - var serialNumber = LOCAL_NUMBER_FORMAT.parse(number.trim()); + var serialNumber = LOCAL_NUMBER_FORMAT.parse(preparedUID); LOCAL_NUMBER_FORMAT.setParseIntegerOnly(false); if (serialNumber.intValue() < 0)