diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2013-02-04 11:03:06 +0000 |
---|---|---|
committer | Paul Gardiner <paulg.artifex@glidos.net> | 2013-02-04 11:03:06 +0000 |
commit | e7aa801e31b29bae1d22554becb2bde96578d313 (patch) | |
tree | 97a720206c822b4c44a0c75b0b7625d9a24caaf8 /android | |
parent | 340bb21f4982d7b6dab8236f8996c86cf2d5a4e2 (diff) | |
download | mupdf-e7aa801e31b29bae1d22554becb2bde96578d313.tar.xz |
Android: handle Unicode correctly in reflow
Diffstat (limited to 'android')
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFCore.java | 2 | ||||
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFReflowView.java | 12 |
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 += "<";break; case '>': res += ">";break; case '&': res += "&";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(); |