think I may have fixed the encoding thing... maybe..... I hope..
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352907 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ab23eab68d
commit
b8f9260d23
@ -55,6 +55,8 @@
|
||||
|
||||
package org.apache.poi.hssf.record;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
|
||||
@ -153,7 +155,12 @@ public class UnicodeString
|
||||
field_2_optionflags = data[ 2 ];
|
||||
if ((field_2_optionflags & 1) == 0)
|
||||
{
|
||||
field_3_string = new String(data, 3, getCharCount());
|
||||
try {
|
||||
field_3_string = new String(data, 3, getCharCount(),
|
||||
StringUtil.getPreferredEncoding());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -75,6 +75,8 @@ import java.text.FieldPosition;
|
||||
*/
|
||||
|
||||
public class StringUtil {
|
||||
|
||||
private final static String ENCODING="ISO-8859-1";
|
||||
/**
|
||||
* Constructor for the StringUtil object
|
||||
*/
|
||||
@ -105,6 +107,7 @@ public class StringUtil {
|
||||
public static String getFromUnicodeHigh(final byte[] string,
|
||||
final int offset, final int len)
|
||||
throws ArrayIndexOutOfBoundsException, IllegalArgumentException {
|
||||
|
||||
if ((offset < 0) || (offset >= string.length)) {
|
||||
throw new ArrayIndexOutOfBoundsException("Illegal offset");
|
||||
}
|
||||
@ -331,4 +334,8 @@ public class StringUtil {
|
||||
numberFormat.format(number, outputTo, new FieldPosition(0));
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static String getPreferredEncoding() {
|
||||
return ENCODING;
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class TestStringUtil
|
||||
* Test putCompressedUnicode
|
||||
*/
|
||||
|
||||
public void testPutCompressedUnicode()
|
||||
public void testPutCompressedUnicode() throws Exception
|
||||
{
|
||||
byte[] output = new byte[ 100 ];
|
||||
byte[] expected_output =
|
||||
@ -215,7 +215,7 @@ public class TestStringUtil
|
||||
( byte ) 'o', ( byte ) ' ', ( byte ) 'W', ( byte ) 'o',
|
||||
( byte ) 'r', ( byte ) 'l', ( byte ) 'd', ( byte ) 0xAE
|
||||
};
|
||||
String input = new String(expected_output);
|
||||
String input = new String(expected_output,StringUtil.getPreferredEncoding());
|
||||
|
||||
StringUtil.putCompressedUnicode(input, output, 0);
|
||||
for (int j = 0; j < expected_output.length; j++)
|
||||
@ -355,4 +355,12 @@ public class TestStringUtil
|
||||
System.out.println("Testing util.StringUtil functionality");
|
||||
junit.textui.TestRunner.run(TestStringUtil.class);
|
||||
}
|
||||
/**
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// System.setProperty()
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user