From 87439307ea60b1f52219c6da44a9efb520a9a6bb Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 18 Aug 2009 14:19:49 -0700 Subject: [PATCH] Make sure Parser always reads UTF-8 strings --- src/com/android/exchange/adapter/Parser.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/com/android/exchange/adapter/Parser.java b/src/com/android/exchange/adapter/Parser.java index 7e494a5fa..f9a005f7b 100644 --- a/src/com/android/exchange/adapter/Parser.java +++ b/src/com/android/exchange/adapter/Parser.java @@ -26,6 +26,7 @@ import org.kxml2.wap.Wbxml; import android.content.Context; import android.util.Log; +import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; @@ -475,8 +476,7 @@ public abstract class Parser { * @throws IOException */ private String readInlineString() throws IOException { - StringBuilder sb = new StringBuilder(256); - + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256); while (true) { int i = read(); if (i == 0) { @@ -484,9 +484,11 @@ public abstract class Parser { } else if (i == EOF_BYTE) { throw new EofException(); } - sb.append((char)i); + outputStream.write(i); } - String res = sb.toString(); + outputStream.flush(); + String res = outputStream.toString("UTF-8"); + outputStream.close(); return res; } } \ No newline at end of file