The getBytes() call with no argument uses the default character set but the line in the email was using the version of get bytes that explicitly specifies unicode as the character set. From what I can tell the code is converting from a unicode string into a unicode byte array and slurping it back up into a new unicode string. Net effect is that it is doing a lot of work for no actual reason.

-- glen

[EMAIL PROTECTED] wrote:

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#getBytes()

public byte[] getBytes()

Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array.

The behavior of this method when this string cannot be encoded in the default charset is unspecified. The CharsetEncoder class should be used when more control over the encoding process is required.

    Returns:
        The resultant byte array
    Since:
        JDK1.1



Glen Stampoultzis wrote:


Aren't Java strings always stored as 2 byte unicode as defined by the spec?

[EMAIL PROTECTED] wrote:

Not all systems default to unicode. Though that looks doofy to me. Your code assumes they do. You'd need a flag saying "amIOnAnAS400()" or something ;-)

-Andy

Jason Height wrote:

All,

Any idea why the following line from UnicodeRecord (current HEAD rev and previous) is actually required? String unicodeString = new String(getString().getBytes("Unicode"),"Unicode");

If i remove it and use:
String unicodeString = getString();

1) All of the unit tests still pass, and
2) There is a 33x performance improvement with workbooks containing a large numbers of strings

I am tempted to apply a patch to use my approach. Any objections?

Jason

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/

Reply via email to