DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10548>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10548

[PATCH] Unicode Support for excel sheetname. Now it made simple. %)

[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[PATCH] Unicode Support for |[PATCH] Unicode Support for
                   |excell sheetname            |excel sheetname. Now it made
                   |                            |simple. %)



------- Additional Comments From [EMAIL PROTECTED]  2002-07-13 19:53 -------
The getting and putting Unicode string now is simple.
Check it and use it. ;)


Index: src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
===================================================================
RCS file: /home/cvspublic/jakarta-
poi/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java,v
retrieving revision 1.4
diff -r1.4 BoundSheetRecord.java
57a58,61
> import java.io.*;
> import java.io.UnsupportedEncodingException;
> 
> import org.apache.poi.util.BinaryTree;
59a64
> import sun.awt.image.ByteInterleavedRaster;
118a124,134
>     
>     /**
>      *  UTF8:
>      *        sid + len + bof + flags + len(str) + unicode +   str
>        *       2  +  2  +  4  +   2   +    1     +    1    + len(str)
>        * 
>        *      UNICODE:
>      *        sid + len + bof + flags + len(str) + unicode +   str
>        *       2  +  2  +  4  +   2   +    1     +    1    + 2 * len(str)
>        * 
>      */
122,130c138,150
<         field_1_position_of_BOF         = LittleEndian.getInt(data,
<                 0 + offset);
<         field_2_option_flags            = LittleEndian.getShort(data,
<                 4 + offset);
<         field_3_sheetname_length        = data[ 6 + offset ];
<         field_4_compressed_unicode_flag = data[ 7 + offset ];
<         field_5_sheetname               = new String(data, 8 + offset,
<                 LittleEndian.ubyteToInt( field_3_sheetname_length));
<     }
---
>         field_1_position_of_BOF         = LittleEndian.getInt(data, 0 + 
offset);        // bof
>         field_2_option_flags            = LittleEndian.getShort(data, 4 + 
offset);        // flags
>         field_3_sheetname_length        = data[ 6 + offset ];                 
                        // len(str)
>         field_4_compressed_unicode_flag = data[ 7 + offset ];                 
                        // unicode
> 
>               int nameLength = LittleEndian.ubyteToInt( 
field_3_sheetname_length );
>         if ( ( field_4_compressed_unicode_flag & 0x01 ) == 1 ) {
>                       field_5_sheetname = StringUtil.getFromUnicode( data, 8 
+ offset, nameLength );
>         }
>         else {
>                       field_5_sheetname = new String( data, 8 + offset, 
nameLength );
>         }
>       }
172c192
<     public void setCompressedUnicodeFlag(byte flag)
---
>     public void setCompressedUnicodeFlag( byte flag )
181,182c201,202
< 
<     public void setSheetname(String sheetname)
---
>     
>     public void setSheetname( String sheetname )
218c238,252
<         return field_3_sheetname_length;
---
>               return field_3_sheetname_length;
>     }
> 
>     /**
>      * get the length of the raw sheetname in characters
>      * the length depends on the unicode flag
>      * 
>      * @return number of characters in the raw sheet name
>      */
> 
>     public byte getRawSheetnameLength()
>     {
>               return (byte)( ( ( field_4_compressed_unicode_flag & 0x01 ) == 
1 )
>                                               ? 2 * field_3_sheetname_length
>                                               : field_3_sheetname_length );
265,266c299
<         LittleEndian.putShort(data, 2 + offset,
<                               ( short ) (0x08 + getSheetnameLength()));
---
>         LittleEndian.putShort( data, 2 + offset, (short)( 8 + 
getRawSheetnameLength() ) );
269c302
<         data[ 10 + offset ] = getSheetnameLength();
---
>         data[ 10 + offset ] = (byte)( getSheetnameLength() );
270a304,309
>         
>         if ( ( field_4_compressed_unicode_flag & 0x01 ) == 1 )
>               StringUtil.putUncompressedUnicode( getSheetname(), data, 12 + 
offset );
>           else
>               StringUtil.putCompressedUnicode( getSheetname(), data, 12 + 
offset );
>               
272,273d310
<         // we assume compressed unicode (bein the dern americans we are ;-p)
<         StringUtil.putCompressedUnicode(getSheetname(), data, 12 + offset);
274a312,332
>         
>               /*
>               byte[] fake = new byte[] {      (byte)0x85, 0x00,               
        // sid
>                                                                       0x1a, 
0x00,                   // length
>                                                                       0x3C, 
0x09, 0x00, 0x00, // bof
>                                                                       0x00, 
0x00,                   // flags
>                                                                       0x09,   
                                // len( str )
>                                                                       0x01,   
                                // unicode
>                                                                       // <str>
>                                                                       0x21, 
0x04, 0x42, 0x04, 0x40, 0x04, 0x30, 0x04, 0x3D, 
>                                                                       0x04, 
0x38, 0x04, 0x47, 0x04, 0x3A, 0x04, 0x30, 0x04   
>                                                                       // 
</str>
>                                                               };
>                                                               
>                                                               sid + len + bof 
+ flags + len(str) + unicode +   str
>                                                                2  +  2  +  4  
+   2   +    1     +    1    + len(str)
>               
>               System.arraycopy( fake, 0, data, offset, fake.length );
>               
>               return fake.length;
>               */
279,280c337,339
<         return 12 + getSheetnameLength();
<     }
---
>         // return 30;
>         return 12 + getRawSheetnameLength();
>       }

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to