mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Separate length and preamble variables
This commit is contained in:
@@ -251,19 +251,20 @@ namespace Microsoft.Iris.Markup
|
|||||||
|
|
||||||
public unsafe string ReadString()
|
public unsafe string ReadString()
|
||||||
{
|
{
|
||||||
uint stringLength = ReadUInt16();
|
uint preamble = ReadUInt16();
|
||||||
if (stringLength == ushort.MaxValue)
|
if (preamble == ushort.MaxValue)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var isUtf16Encoded = ((int)stringLength & (1 << 15)) == 0;
|
var isUtf16Encoded = ((int)preamble & (1 << 15)) == 0;
|
||||||
uint byteCount;
|
uint byteCount, stringLength;
|
||||||
if (isUtf16Encoded)
|
if (isUtf16Encoded)
|
||||||
{
|
{
|
||||||
|
stringLength = preamble;
|
||||||
byteCount = stringLength * 2U;
|
byteCount = stringLength * 2U;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stringLength &= (uint)short.MaxValue;
|
stringLength = preamble & (uint)short.MaxValue;
|
||||||
byteCount = stringLength;
|
byteCount = stringLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -137,11 +137,11 @@ namespace Microsoft.Iris.Markup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint length = (uint)value.Length;
|
uint preamble = (uint)value.Length;
|
||||||
if (!useUtf16)
|
if (!useUtf16)
|
||||||
length |= 1 << 15;
|
preamble |= 1 << 15;
|
||||||
|
|
||||||
WriteUInt16((ushort)length);
|
WriteUInt16((ushort)preamble);
|
||||||
|
|
||||||
foreach (char ch in value)
|
foreach (char ch in value)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user