From 841a2eda18f7ceec292302e04cba4f326eb85672 Mon Sep 17 00:00:00 2001 From: Enrique Zamudio Date: Fri, 30 Nov 2012 11:39:02 -0600 Subject: [PATCH] use character encoding (thanks @dhinckle2) --- .../java/com/solab/iso8583/parse/AmountParseInfo.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/solab/iso8583/parse/AmountParseInfo.java b/src/main/java/com/solab/iso8583/parse/AmountParseInfo.java index 26337d7..c724285 100644 --- a/src/main/java/com/solab/iso8583/parse/AmountParseInfo.java +++ b/src/main/java/com/solab/iso8583/parse/AmountParseInfo.java @@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ package com.solab.iso8583.parse; +import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.text.ParseException; @@ -36,18 +37,19 @@ public class AmountParseInfo extends FieldParseInfo { super(IsoType.AMOUNT, 12); } - public IsoValue parse(byte[] buf, int pos, CustomField custom) throws ParseException { + public IsoValue parse(byte[] buf, int pos, CustomField custom) + throws ParseException, UnsupportedEncodingException { if (pos < 0) { throw new ParseException(String.format("Invalid AMOUNT position %d", pos), pos); } if (pos+12 > buf.length) { throw new ParseException(String.format("Insufficient data for AMOUNT field, pos %d", pos), pos); } - String c = new String(buf, pos, 12); + String c = new String(buf, pos, 12, getCharacterEncoding()); try { return new IsoValue(type, new BigDecimal(c).movePointLeft(2), null); } catch (NumberFormatException ex) { - throw new ParseException(String.format("Cannot read amount '%s' pos %d", new String(c), pos), pos); + throw new ParseException(String.format("Cannot read amount '%s' pos %d", c, pos), pos); } }