private void AppendString(string str)
{
int L = str.Length;
int lengthEncodingSize = 1;
if (L >= unchecked((int)(0x8000)))
{
lengthEncodingSize = 2;
}
int nextTop = sourceTop + lengthEncodingSize + L;
if (nextTop > sourceBuffer.Length)
{
IncreaseSourceCapacity(nextTop);
}
if (L >= unchecked((int)(0x8000)))
{
// Use 2 chars to encode strings exceeding 32K, were the highest
// bit in the first char indicates presence of the next byte
sourceBuffer[sourceTop] = (char)(unchecked((int)(0x8000)) | ((int)(((uint)L) >> 16)));
++sourceTop;
}
sourceBuffer[sourceTop] = (char)L;
++sourceTop;
Sharpen.Runtime.GetCharsForString(str, 0, L, sourceBuffer, sourceTop);
sourceTop = nextTop;
}