You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by ac...@apache.org on 2003/04/22 18:29:44 UTC
cvs commit: jakarta-poi/src/java/org/apache/poi/util StringUtil.java
acoliver 2003/04/22 09:29:43
Modified: src/java/org/apache/poi/hssf/record BoundSheetRecord.java
FontRecord.java FooterRecord.java FormatRecord.java
HeaderRecord.java LabelRecord.java NameRecord.java
StringRecord.java StyleRecord.java
WriteAccessRecord.java
src/java/org/apache/poi/util StringUtil.java
Log:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18947
Revision Changes Path
1.7 +1 -1 jakarta-poi/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
Index: BoundSheetRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BoundSheetRecord.java 27 Jul 2002 01:46:44 -0000 1.6
+++ BoundSheetRecord.java 22 Apr 2003 16:29:42 -0000 1.7
@@ -142,7 +142,7 @@
}
else
{
- field_5_sheetname = new String( data, 8 + offset, nameLength );
+ field_5_sheetname = StringUtil.getFromCompressedUnicode( data, 8 + offset, nameLength );
}
}
1.7 +1 -1 jakarta-poi/src/java/org/apache/poi/hssf/record/FontRecord.java
Index: FontRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/FontRecord.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FontRecord.java 13 Sep 2002 11:27:17 -0000 1.6
+++ FontRecord.java 22 Apr 2003 16:29:42 -0000 1.7
@@ -164,7 +164,7 @@
{
if (data[ 15 ] == 0)
{ // is compressed unicode
- field_11_font_name = new String(data, 16,
+ field_11_font_name = StringUtil.getFromCompressedUnicode(data, 16,
LittleEndian.ubyteToInt(field_10_font_name_len));
}
else
1.9 +1 -1 jakarta-poi/src/java/org/apache/poi/hssf/record/FooterRecord.java
Index: FooterRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/FooterRecord.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FooterRecord.java 5 Oct 2002 02:38:06 -0000 1.8
+++ FooterRecord.java 22 Apr 2003 16:29:42 -0000 1.9
@@ -119,7 +119,7 @@
if (size > 0)
{
field_1_footer_len = data[ 0 + offset ];
- field_2_footer = new String(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string
+ field_2_footer = StringUtil.getFromCompressedUnicode(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string
LittleEndian.ubyteToInt( field_1_footer_len) );
}
}
1.8 +1 -1 jakarta-poi/src/java/org/apache/poi/hssf/record/FormatRecord.java
Index: FormatRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/FormatRecord.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FormatRecord.java 5 Oct 2002 02:38:06 -0000 1.7
+++ FormatRecord.java 22 Apr 2003 16:29:42 -0000 1.8
@@ -132,7 +132,7 @@
}
else {
// not unicode
- field_4_formatstring = new String(data, 5 + offset, field_3_unicode_len );
+ field_4_formatstring = StringUtil.getFromCompressedUnicode(data, 5 + offset, field_3_unicode_len );
}
}
1.9 +1 -1 jakarta-poi/src/java/org/apache/poi/hssf/record/HeaderRecord.java
Index: HeaderRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/HeaderRecord.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- HeaderRecord.java 5 Oct 2002 02:38:06 -0000 1.8
+++ HeaderRecord.java 22 Apr 2003 16:29:42 -0000 1.9
@@ -119,7 +119,7 @@
if (size > 0)
{
field_1_header_len = data[ 0 + offset ];
- field_2_header = new String(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string
+ field_2_header = StringUtil.getFromCompressedUnicode(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string
LittleEndian.ubyteToInt(field_1_header_len));
}
}
1.5 +1 -1 jakarta-poi/src/java/org/apache/poi/hssf/record/LabelRecord.java
Index: LabelRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/LabelRecord.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LabelRecord.java 5 Sep 2002 00:26:23 -0000 1.4
+++ LabelRecord.java 22 Apr 2003 16:29:42 -0000 1.5
@@ -157,7 +157,7 @@
}
else
{
- field_6_value = new String(data, 9 + offset, getStringLength());
+ field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset, getStringLength());
}
}
1.10 +5 -5 jakarta-poi/src/java/org/apache/poi/hssf/record/NameRecord.java
Index: NameRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/NameRecord.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- NameRecord.java 6 Mar 2003 20:41:16 -0000 1.9
+++ NameRecord.java 22 Apr 2003 16:29:42 -0000 1.10
@@ -756,7 +756,7 @@
field_12_builtIn_name = data[ 15 + offset ];
}
- field_12_name_text = new String(data, 15 + offset,
+ field_12_name_text = StringUtil.getFromCompressedUnicode(data, 15 + offset,
LittleEndian.ubyteToInt(field_3_length_name_text));
int start_of_name_definition = 15 + field_3_length_name_text;
@@ -764,19 +764,19 @@
offset, start_of_name_definition);
int start_of_custom_menu_text = start_of_name_definition + field_4_length_name_definition;
- field_14_custom_menu_text = new String(data, start_of_custom_menu_text + offset,
+ field_14_custom_menu_text = StringUtil.getFromCompressedUnicode(data, start_of_custom_menu_text + offset,
LittleEndian.ubyteToInt(field_7_length_custom_menu));
int start_of_description_text = start_of_custom_menu_text + field_8_length_description_text;
- field_15_description_text = new String(data, start_of_description_text + offset,
+ field_15_description_text = StringUtil.getFromCompressedUnicode(data, start_of_description_text + offset,
LittleEndian.ubyteToInt(field_8_length_description_text));
int start_of_help_topic_text = start_of_description_text + field_9_length_help_topic_text;
- field_16_help_topic_text = new String(data, start_of_help_topic_text + offset,
+ field_16_help_topic_text = StringUtil.getFromCompressedUnicode(data, start_of_help_topic_text + offset,
LittleEndian.ubyteToInt(field_9_length_help_topic_text));
int start_of_status_bar_text = start_of_help_topic_text + field_10_length_status_bar_text;
- field_17_status_bar_text = new String(data, start_of_status_bar_text + offset,
+ field_17_status_bar_text = StringUtil.getFromCompressedUnicode(data, start_of_status_bar_text + offset,
LittleEndian.ubyteToInt(field_10_length_status_bar_text));
/*} */
}
1.4 +1 -1 jakarta-poi/src/java/org/apache/poi/hssf/record/StringRecord.java
Index: StringRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/StringRecord.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StringRecord.java 20 Mar 2003 20:01:13 -0000 1.3
+++ StringRecord.java 22 Apr 2003 16:29:42 -0000 1.4
@@ -134,7 +134,7 @@
}
else
{
- field_3_string = new String(data, 3 + offset, field_1_string_length);
+ field_3_string = StringUtil.getFromCompressedUnicode(data, 3 + offset, field_1_string_length);
}
}
1.5 +1 -1 jakarta-poi/src/java/org/apache/poi/hssf/record/StyleRecord.java
Index: StyleRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/StyleRecord.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StyleRecord.java 1 Mar 2002 13:27:10 -0000 1.4
+++ StyleRecord.java 22 Apr 2003 16:29:42 -0000 1.5
@@ -134,7 +134,7 @@
else if (getType() == 0)
{
field_2_name_length = data[ 2 + offset ];
- field_3_name = new String(data, 3 + offset,
+ field_3_name = StringUtil.getFromCompressedUnicode(data, 3 + offset,
LittleEndian.ubyteToInt(field_2_name_length));
}
1.3 +1 -1 jakarta-poi/src/java/org/apache/poi/hssf/record/WriteAccessRecord.java
Index: WriteAccessRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/WriteAccessRecord.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WriteAccessRecord.java 11 Feb 2002 03:49:39 -0000 1.2
+++ WriteAccessRecord.java 22 Apr 2003 16:29:42 -0000 1.3
@@ -115,7 +115,7 @@
protected void fillFields(byte [] data, short size, int offset)
{
- field_1_username = new String(data, 3 + offset, data.length - 4);
+ field_1_username = StringUtil.getFromCompressedUnicode(data, 3 + offset, data.length - 4);
}
/**
1.9 +20 -0 jakarta-poi/src/java/org/apache/poi/util/StringUtil.java
Index: StringUtil.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/util/StringUtil.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- StringUtil.java 8 Nov 2002 02:49:51 -0000 1.8
+++ StringUtil.java 22 Apr 2003 16:29:43 -0000 1.9
@@ -197,6 +197,26 @@
}
+ /**
+ * read compressed unicode(8bit)
+ *
+ * @author Toshiaki Kamoshida(kamoshida.toshiaki at future dot co dot jp)
+ *
+ * @param string byte array to read
+ * @param offset offset to read byte array
+ * @param len length to read byte array
+ * @return String generated String instance by reading byte array
+ */
+ public static String getFromCompressedUnicode(final byte[] string,
+ final int offset, final int len){
+ try{
+ return new String(string,offset,len,"ISO-8859-1");
+ }
+ catch(UnsupportedEncodingException e){
+ throw new InternalError();/* unreachable */
+ }
+ }
+
/**
* write compressed unicode
*