https://bz.apache.org/bugzilla/show_bug.cgi?id=69667

Jason Slater <jason.sla...@ring-zero.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Jason Slater <jason.sla...@ring-zero.com> ---
I have extracted the situation out to 3 lines of code which reproduce what I'm
seeing

      byte[] data = new byte[] { (byte) 68, (byte) 0, (byte) 97, (byte) 0,
(byte) 116, (byte) 0, (byte) 97, (byte) 0, (byte) 32, (byte) 0, (byte) 68,
(byte) 0, (byte) 121, (byte) 0, (byte) 110, (byte) 0, (byte) 97, (byte) 0,
(byte) 109, (byte) 0, (byte) 105, (byte) 0, (byte) 99, (byte) 0, (byte) 115,
(byte) 0, (byte) 39, (byte) 0, (byte) 32, (byte) 0, (byte) 83, (byte) 0, (byte)
112, (byte) 0, (byte) 114, (byte) 0, (byte) 101, (byte) 0, (byte) 97, (byte) 0,
(byte) 100, (byte) 0, (byte) 66, (byte) 0, (byte) 117, (byte) 0, (byte) 105,
(byte) 0, (byte) 108, (byte) 0, (byte) 100, (byte) 0, (byte) 101, (byte) 0,
(byte) 114, (byte) 0, (byte) 32, (byte) 0, (byte) 32, (byte) 0, (byte) 32,
(byte) 0, (byte) 32, (byte) 0, (byte) 32, (byte) 0, (byte) 32, (byte) 0, (byte)
32, (byte) 0, (byte) 32, (byte) 0, (byte) 32, (byte) 0, (byte) 32, (byte) 0,
(byte) 32, (byte) 0, (byte) 32, (byte) 0, (byte) 32, (byte) 0, (byte) 32,
(byte) 0, (byte) 32, (byte) 0, (byte) 32, (byte) 0, (byte) 32, (byte) 0, (byte)
32, (byte) 0, (byte) 32, (byte) 0, (byte) 32, (byte) 0, (byte) 32, (byte) 0,
(byte) 32, (byte) 0, (byte) 32, (byte) 0, (byte) 32, (byte) 0, (byte) 32,
(byte) 0, (byte) 32, (byte) 0, (byte) 32 };
      String rawValue = new String(data, 0, 109, Charset.forName("UTF-16LE") );
      System.out.println( rawValue );


if I change to length=108 for String constructor, problem solved
String rawValue = new String(data, 0, 108, Charset.forName("UTF-16LE") );

if I add an additional (byte) 0 to the array (so that the total length of the
data is 110) and change to length=110 for String constructor, problem solved
String rawValue = new String(data, 0, 110, Charset.forName("UTF-16LE") );

so the problem occurs when trying to create a UTF-16LE string from an odd
number of characters.  

    private static final int DATA_SIZE = 112;
    private static final int STRING_SIZE = DATA_SIZE - 3;
    data = IOUtils.safelyAllocate(in.remaining(), STRING_SIZE); <--- perhaps
the solution is to allocate data byte array with length=112 (DATA_SIZE) instead
of length=109 (STRING_SIZE)?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to