Exemple #1
0
		public static void ReadPrimitive(IoBuffer buffer, out string value)
		{
			uint len;
			ReadPrimitive(buffer, out len);

			if (len == 0)
			{
				value = null;
				return;
			}
			else if (len == 1)
			{
				value = string.Empty;
				return;
			}

			len -= 1;

			var encoding = new UTF8Encoding(false, true);

			var buf = new byte[len];

			int l = 0;

			while (l < len)
			{
				int r = buffer.Read(buf, l, (int)len - l);
				if (r == 0)
					throw new EndOfIoBufferException();
				l += r;
			}

			value = encoding.GetString(buf);
		}