<!-- Don't forget to update status.xml too! -->
<release version="3.5-beta6" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">47179 - Fix string encoding issues with HSMF chunks on non-windows platforms</action>
<action dev="POI-DEVELOPERS" type="add">47183 - Attachment support for HSMF</action>
<action dev="POI-DEVELOPERS" type="fix">47154 - Handle the cell format @ as the same as General</action>
<action dev="POI-DEVELOPERS" type="fix">47048 - Fixed evaluation of defined names with the 'complex' flag set</action>
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.5-beta6" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">47179 - Fix string encoding issues with HSMF chunks on non-windows platforms</action>
<action dev="POI-DEVELOPERS" type="add">47183 - Attachment support for HSMF</action>
<action dev="POI-DEVELOPERS" type="fix">47154 - Handle the cell format @ as the same as General</action>
<action dev="POI-DEVELOPERS" type="fix">47048 - Fixed evaluation of defined names with the 'complex' flag set</action>
package org.apache.poi.hsmf.datatypes;
import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.poi.hsmf.datatypes.Types;
/**
* A Chunk made up of a single string.
* @see org.apache.poi.hsmf.Chunk.Chunk#setValue(java.io.ByteArrayOutputStream)
*/
public void setValue(ByteArrayOutputStream value) {
- this.value = value.toString().replaceAll("\0", "");
+ String tmpValue;
+ if (type == Types.NEW_STRING) {
+ try {
+ tmpValue = new String(value.toByteArray(), "UTF-16LE");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException("Core encoding not found, JVM broken?", e);
+ }
+ } else {
+ try {
+ tmpValue = new String(value.toByteArray(), "CP1252");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException("Core encoding not found, JVM broken?", e);
+ }
+ }
+ this.value = tmpValue.replace("\0", "");
}
public String toString() {
String obtained = mapiMessage.getDisplayCC();
String expected = "";
- TestCase.assertEquals(obtained, expected);
+ TestCase.assertEquals(expected, obtained);
}
/**
String obtained = mapiMessage.getDisplayTo();
String expected = "";
- TestCase.assertEquals(obtained, expected);
+ TestCase.assertEquals(expected, obtained);
}
/**
String obtained = mapiMessage.getDisplayBCC();
String expected = "";
- TestCase.assertEquals(obtained, expected);
+ TestCase.assertEquals(expected, obtained);
}