|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.IO
{
internal static class BinaryWriterExtensions
{
public static void Write7BitEncodedInt(this BinaryWriter writer, int value)
{
// Write out an int 7 bits at a time. The high bit of the byte,
// when on, tells reader to continue reading more bytes.
uint v = (uint)value; // support negative numbers
while (v >= 0x80)
{
writer.Write((byte)(v | 0x80));
v >>= 7;
}
writer.Write((byte)v);
}
}
}
|