]> source.dussan.org Git - poi.git/commitdiff
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18947
authorAndrew C. Oliver <acoliver@apache.org>
Tue, 22 Apr 2003 16:29:43 +0000 (16:29 +0000)
committerAndrew C. Oliver <acoliver@apache.org>
Tue, 22 Apr 2003 16:29:43 +0000 (16:29 +0000)
PR:
Obtained from:
Submitted by:
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353064 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
src/java/org/apache/poi/hssf/record/FontRecord.java
src/java/org/apache/poi/hssf/record/FooterRecord.java
src/java/org/apache/poi/hssf/record/FormatRecord.java
src/java/org/apache/poi/hssf/record/HeaderRecord.java
src/java/org/apache/poi/hssf/record/LabelRecord.java
src/java/org/apache/poi/hssf/record/NameRecord.java
src/java/org/apache/poi/hssf/record/StringRecord.java
src/java/org/apache/poi/hssf/record/StyleRecord.java
src/java/org/apache/poi/hssf/record/WriteAccessRecord.java
src/java/org/apache/poi/util/StringUtil.java

index 3202baae3947c20a33d952042ef1d6442e2f6cb8..c18a202bb56700b79558fb6e503c8739e32e2dcc 100644 (file)
@@ -142,7 +142,7 @@ public class BoundSheetRecord
         }
         else
         {
-            field_5_sheetname = new String( data, 8 + offset, nameLength );
+            field_5_sheetname = StringUtil.getFromCompressedUnicode( data, 8 + offset, nameLength );
         }
     }
 
index a7bd970efe01edb0dd8161af6be53d57e733b826..332f2b304a57f27beec1c54c95e4ae901b325bb7 100644 (file)
@@ -164,7 +164,7 @@ public class FontRecord
         {
             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
index 879a9036a0b362bce0da0d39b840024f94c8998e..4082c16ee4103a2ef378a26be5da19fa08540617 100644 (file)
@@ -119,7 +119,7 @@ public class FooterRecord
         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) );
         }
     }
index 5dd1b01572012addf255a1978127455d670f58e6..4feaee674c176b0ec7456286dcc3ac40f4ec6eea 100644 (file)
@@ -132,7 +132,7 @@ public class FormatRecord
       }
       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 );
       }
     }
 
index 3883317fb701958f567cf711cb6a7e81f2003798..c87ed258967e288d10b0c9aa819fe702091a58f9 100644 (file)
@@ -119,7 +119,7 @@ public class HeaderRecord
         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));
         }
     }
index 9a7d73dd2e7cd33a6a5ae2fbcffdd4db7ea75715..171d65abb35d0b9d854321854006a69e0f5bee0e 100644 (file)
@@ -157,7 +157,7 @@ public class LabelRecord
         }
         else
         {
-            field_6_value = new String(data, 9 + offset, getStringLength());
+            field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset, getStringLength());
         }
     }
 
index 406b06b23ca6a043d9c0266165ba6cabe162a4f0..dab759746404fcdbe0bf41447a944064393b39e4 100644 (file)
@@ -756,7 +756,7 @@ public class NameRecord extends Record {
                                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 @@ public class NameRecord extends Record {
             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));
         /*} */
     }
index 6b6cdea241490d926c8c18c83f8a9eb1ad07ddd0..2e5fc734c4fc87952279032b6d9188350942144e 100644 (file)
@@ -134,7 +134,7 @@ public class StringRecord
         }
         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);
         }
     }
 
index 3ce8c4ea9184560c509b510c5d8556a49d240dd1..2a5a63bea02f70c84fe25387274c7db86ae3ec69 100644 (file)
@@ -134,7 +134,7 @@ public class StyleRecord
         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));
         }
 
index c35b94c851f59b745d011af9be1964214803aae6..698997f539a273f0e437f16069393bcccd84fd92 100644 (file)
@@ -115,7 +115,7 @@ public class WriteAccessRecord
 
     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);
     }
 
     /**
index 378b1af0ae421ca18459d5dd409e194f80bf5f78..f1e16c707a1b2b99a2efef6428f76e3c70e7d4f5 100644 (file)
@@ -197,6 +197,26 @@ public class StringUtil {
     }
 
 
+      /**
+      * 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
      *