summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorPaul Gardiner <paulg.artifex@glidos.net>2013-02-04 11:03:06 +0000
committerPaul Gardiner <paulg.artifex@glidos.net>2013-02-04 11:03:06 +0000
commite7aa801e31b29bae1d22554becb2bde96578d313 (patch)
tree97a720206c822b4c44a0c75b0b7625d9a24caaf8 /android
parent340bb21f4982d7b6dab8236f8996c86cf2d5a4e2 (diff)
downloadmupdf-e7aa801e31b29bae1d22554becb2bde96578d313.tar.xz
Android: handle Unicode correctly in reflow
Diffstat (limited to 'android')
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFCore.java2
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFReflowView.java12
2 files changed, 12 insertions, 2 deletions
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFCore.java b/android/src/com/artifex/mupdfdemo/MuPDFCore.java
index 356fd31d..68c38a7f 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFCore.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFCore.java
@@ -218,7 +218,7 @@ public class MuPDFCore
case '<': res += "&lt;";break;
case '>': res += "&gt;";break;
case '&': res += "&amp;";break;
- default: res += (tc.c >= 32 && tc.c <= 127) ? tc.c : "#x"+Integer.toHexString(tc.c);
+ default: res += tc.c;
}
}
}
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java b/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java
index 450f2c53..8a26c8e6 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java
@@ -1,9 +1,12 @@
package com.artifex.mupdfdemo;
+import java.io.UnsupportedEncodingException;
+
import android.content.Context;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.RectF;
+import android.util.Base64;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebView;
@@ -46,7 +49,14 @@ public class MuPDFReflowView extends WebView implements MuPDFView {
}
@Override
protected void onPostExecute(String result) {
- loadData(result, "text/html", null);
+ byte [] utf8;
+ try {
+ utf8 = result.getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ utf8 = result.getBytes();
+ }
+ String b64 = Base64.encodeToString(utf8, Base64.DEFAULT);
+ loadData(b64, "text/html; charset=utf-8", "base64");
}
};
mLoadHTML.execute();