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

--- Comment #2 from Jason Slater <jason.sla...@ring-zero.com> ---
I downloaded the code and created a unit test

@Test
void testUTF16LE() {

    byte[] data = HexRead.readFromString(""
                    + "5c 00 70 00 51 00 01 "
                    + "44 00 61 00 74 00 61 00 20 00 44 00 79 00 6e 00 "
                    + "61 00 6d 00 69 00 63 00 73 00 27 00 20 00 53 00 "
                    + "70 00 72 00 65 00 61 00 64 00 42 00 75 00 69 00 "
                    + "6c 00 64 00 65 00 72 00 20 00 20 00 20 00 20 00 "
                    + "20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 "
                    + "20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 "
                    + "20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 "
                    + "20 00 20 00 20 00"
    );
    RecordInputStream in = TestcaseRecordInputStream.create(data);

    WriteAccessRecord rec = new WriteAccessRecord(in);

    assertEquals("Data Dynamics' SpreadBuilder", rec.getUsername());

}


this will fail in the WriteAccessRecord(RecordInputStream in) constructor
unless I correct the byte count to an even number...

        } else {
            // the normal case ...
            data = IOUtils.safelyAllocate(in.remaining(), STRING_SIZE);
            in.readFully(data);
            if (UTF16FLAG.isSet(is16BitFlag)) {
                byteCnt = Math.min(nChars * 2, data.length);
                if (byteCnt % 2 == 1) byteCnt -= 1; <----------- Odd -> Even
                charset = StandardCharsets.UTF_16LE;
            } else {
                byteCnt = Math.min(nChars, data.length);
                charset = StandardCharsets.ISO_8859_1;
            }
        }

if anyone wants to offer any thoughts, I'm all ears

-- 
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