// Token: 0x060000BE RID: 190 RVA: 0x000067B4 File Offset: 0x000049B4 public unsafe static void WritePrimitive(Stream stream, string value) { if (value == null) { Primitives.WritePrimitive(stream, 0U); return; } if (value.Length == 0) { Primitives.WritePrimitive(stream, 1U); return; } Primitives.StringHelper stringHelper = Primitives.s_stringHelper; if (stringHelper == null) { stringHelper = (Primitives.s_stringHelper = new Primitives.StringHelper()); } Encoder encoder = stringHelper.Encoder; byte[] byteBuffer = stringHelper.ByteBuffer; int length = value.Length; int byteCount; fixed(char *chars = value) { byteCount = encoder.GetByteCount(chars, length, true); } Primitives.WritePrimitive(stream, (uint)(byteCount + 1)); Primitives.WritePrimitive(stream, (uint)length); int num = 0; bool flag = false; while (!flag) { int num2; int count; fixed(char *ptr = value) { byte[] array; byte * ptr2; if ((array = byteBuffer) != null && array.Length != 0) { fixed(byte *ptr2 = &array[0]) { } } else { ptr2 = null; } encoder.Convert(ptr + num, length - num, ptr2, byteBuffer.Length, true, out num2, out count, out flag); ptr2 = null; } stream.Write(byteBuffer, 0, count); num += num2; } }
// Token: 0x060000BF RID: 191 RVA: 0x000068A8 File Offset: 0x00004AA8 public static void ReadPrimitive(Stream stream, out string value) { uint num; Primitives.ReadPrimitive(stream, out num); if (num == 0U) { value = null; return; } if (num == 1U) { value = string.Empty; return; } num -= 1U; uint num2; Primitives.ReadPrimitive(stream, out num2); Primitives.StringHelper stringHelper = Primitives.s_stringHelper; if (stringHelper == null) { stringHelper = (Primitives.s_stringHelper = new Primitives.StringHelper()); } Decoder decoder = stringHelper.Decoder; byte[] byteBuffer = stringHelper.ByteBuffer; char[] array; if (num2 <= 128U) { array = stringHelper.CharBuffer; } else { array = new char[num2]; } int i = (int)num; int num3 = 0; while (i > 0) { int num4 = stream.Read(byteBuffer, 0, Math.Min(byteBuffer.Length, i)); if (num4 == 0) { throw new EndOfStreamException(); } i -= num4; bool flush = i == 0; bool flag = false; int num5 = 0; while (!flag) { int num6; int num7; decoder.Convert(byteBuffer, num5, num4 - num5, array, num3, (int)(num2 - (uint)num3), flush, out num6, out num7, out flag); num5 += num6; num3 += num7; } } value = new string(array, 0, (int)num2); }