Skip to content

Commit

Permalink
Fixing #98 logic for LPWSTR, fixing test [Test_SUMMARY_INFO_READ_LPWS…
Browse files Browse the repository at this point in the history
…TRING_VECTOR] for null terminator character suppression in User presentation,
  • Loading branch information
ironfede committed Aug 6, 2024
1 parent 390dcb3 commit cac87ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@ public VT_LPWSTR_Property(VTPropertyType vType, int codePage, bool isVariant) :
public override string ReadScalarValue(System.IO.BinaryReader br)
{
uint nChars = br.ReadUInt32();
data = br.ReadBytes((int)((nChars * 2) - 2)); //WChar- null terminator
data = br.ReadBytes((int)(((nChars-1) * 2))); //WChar- null terminator
br.ReadBytes(2); // Skip null terminator
var result = Encoding.Unicode.GetString(data);
//result = result.Trim(new char[] { '\0' });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,9 @@ public void Test_SUMMARY_INFO_READ_LPWSTRING_VECTOR()

var docPartsValues = docPartsProperty.Value as IEnumerable<string>;
Assert.AreEqual(3, docPartsValues.Count());
Assert.AreEqual("Sheet1\0", docPartsValues.ElementAt(0));
Assert.AreEqual("Sheet2\0", docPartsValues.ElementAt(1));
Assert.AreEqual("Sheet3\0", docPartsValues.ElementAt(2));
Assert.AreEqual("Sheet1", docPartsValues.ElementAt(0));
Assert.AreEqual("Sheet2", docPartsValues.ElementAt(1));
Assert.AreEqual("Sheet3", docPartsValues.ElementAt(2));
}
}

Expand Down

0 comments on commit cac87ec

Please sign in to comment.