private static void WriteChars(string pString, IStreamOutput pOutput) { if (pString == null) { pOutput.WriteInt(255); return; } int length = pString.Length; // pString.Length == index 3 if (length >= 128) { // offset 7 pOutput.WriteByte(length >> 16 | 0x80); pOutput.WriteByte(length >> 8 & 0xff); pOutput.WriteByte(length & 0xff); } //offset 16 pOutput.WriteByte(length); if (length > 0) { pOutput.WriteChars(pString); } }