From e86f151724a18d9623200baad4433df78aed5f79 Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Sun, 2 Oct 2011 08:44:05 +0000 Subject: [PATCH] fix VT_LPWSTR support git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1178149 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hpsf/VariantSupport.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/java/org/apache/poi/hpsf/VariantSupport.java b/src/java/org/apache/poi/hpsf/VariantSupport.java index ecb486b94b..f1752de8a0 100644 --- a/src/java/org/apache/poi/hpsf/VariantSupport.java +++ b/src/java/org/apache/poi/hpsf/VariantSupport.java @@ -505,19 +505,23 @@ public class VariantSupport extends Variant } case Variant.VT_LPWSTR: { - final int nrOfChars = ((String) value).length() + 1; - length += TypeWriter.writeUIntToStream(out, nrOfChars); - char[] s = Util.pad4((String) value); - for (int i = 0; i < s.length; i++) + final int nrOfChars = ( (String) value ).length() + 1; + length += TypeWriter.writeUIntToStream( out, nrOfChars ); + char[] s = ( (String) value ).toCharArray(); + for ( int i = 0; i < s.length; i++ ) { - final int high = ((s[i] & 0x0000ff00) >> 8); - final int low = (s[i] & 0x000000ff); + final int high = ( ( s[i] & 0x0000ff00 ) >> 8 ); + final int low = ( s[i] & 0x000000ff ); final byte highb = (byte) high; final byte lowb = (byte) low; - out.write(lowb); - out.write(highb); + out.write( lowb ); + out.write( highb ); length += 2; } + // NullTerminator + out.write( 0x00 ); + out.write( 0x00 ); + length += 2; break; } case Variant.VT_CF: -- 2.39.5