From 0c9120905f67873b3b539d85f516c132adf2986d Mon Sep 17 00:00:00 2001 From: Jason Height Date: Fri, 2 Sep 2005 03:41:40 +0000 Subject: [PATCH] UnicodeString now does not do the peculiar new String(getBytes("Unicode"),"Unicode") when serializing. I doubt that this will have an effect on the serialization on non UTF8 platforms, but not having one of these to test on i dont know for 100%. Please if anyone can try this with their code with a non-8bit character set please do and let us know of any issues git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353777 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hssf/record/UnicodeString.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/java/org/apache/poi/hssf/record/UnicodeString.java b/src/java/org/apache/poi/hssf/record/UnicodeString.java index 07003d3cbb..9121a0968d 100644 --- a/src/java/org/apache/poi/hssf/record/UnicodeString.java +++ b/src/java/org/apache/poi/hssf/record/UnicodeString.java @@ -19,6 +19,7 @@ package org.apache.poi.hssf.record; import org.apache.poi.util.BitField; +import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.HexDump; @@ -48,9 +49,9 @@ public class UnicodeString private String field_3_string; // = null; private List field_4_format_runs; private byte[] field_5_ext_rst; - private BitField highByte = new BitField(0x1); - private BitField extBit = new BitField(0x4); - private BitField richText = new BitField(0x8); + private BitField highByte = BitFieldFactory.getInstance(0x1); + private BitField extBit = BitFieldFactory.getInstance(0x4); + private BitField richText = BitFieldFactory.getInstance(0x8); public static class FormatRun implements Comparable { private short character; @@ -550,8 +551,7 @@ public class UnicodeString byte[] strBytes = null; try { - //JMH Why does this do this? - String unicodeString = new String(getString().getBytes("Unicode"),"Unicode"); + String unicodeString = getString(); if (!isUncompressedUnicode()) { strBytes = unicodeString.getBytes("ISO-8859-1"); @@ -562,17 +562,8 @@ public class UnicodeString } } catch (Exception e) { - try { - if (!isUncompressedUnicode()) { - strBytes = getString().getBytes("ISO-8859-1"); - } - else { - strBytes = getString().getBytes("UTF-16LE"); - } - } catch (Exception ex) { throw new InternalError(); } - } if (strSize != strBytes.length) throw new InternalError("That shouldnt have happened!");