public string GetStringAsUtf16()
{
int i, stringBytes = 0;
for (i = ReadBytes; i < BufferSize; i += 2)
{
if (Buffer[i + 0] == 0
&& Buffer[i + 1] == 0)
break;
stringBytes += 2;
if (ReadBytes + stringBytes + 2 > WrittenBytes)
throw new AegisException(AegisResult.BufferUnderflow, "No more readable buffer.");
}
// String으로 변환할 때 Null terminate를 포함시켜서는 안된다.
string val = Encoding.Unicode.GetString(Buffer, ReadBytes, stringBytes);
ReadBytes += stringBytes + 2;
return val;
}