From f2b754b03a2c1c4ff20c2c34387ecfcdc3ce1c16 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Mon, 6 Jul 2015 09:11:16 +0200 Subject: added encoding decoding functions for UTF16 strings --- .../at/gv/egiz/pdfas/common/utils/StringUtils.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'pdf-as-common') diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java index dbea3c70..436fc95e 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java @@ -78,6 +78,24 @@ public class StringUtils { return value; } + public static String transformToUTF16(String test) + throws UnsupportedEncodingException{ + byte[] bytes = test.getBytes("UTF-8"); + return new String(bytes, "UTF-8"); + } + + public static byte[] applyUTF16Encoding(String text) + throws UnsupportedEncodingException{ + byte[] replace_bytes; + replace_bytes = text.getBytes("UTF-8"); + return replace_bytes; + } + + public static String unapplyUTF16Encoding(byte[] replace_bytes) throws UnsupportedEncodingException { + String text = new String(replace_bytes, "UTF-8"); + return text; + } + public static byte[] applyWinAnsiEncoding(String text) throws UnsupportedEncodingException { byte[] replace_bytes; -- cgit v1.2.3