public WriteString32 ( String text ) : void | ||
text | String | A string |
Результат | void |
public void WriteString32(String text)
{
if(text != null)
{
char[] charr = text.ToCharArray();
uint utfLength = CountUtf8Bytes(charr);
if(utfLength > int.MaxValue)
{
throw new IOException(
String.Format(
"Cannot marshall an encoded string longer than: {0} bytes, supplied" +
"string requires: {1} characters to encode", int.MaxValue, utfLength));
}
byte[] bytearr = new byte[utfLength];
encodeUTF8toBuffer(charr, bytearr);
Write(utfLength);
Write(bytearr);
}
else
{
Write((int) -1);
}
}
protected void SetContent(Message message, String text) { MemoryStream mstream = new MemoryStream(); EndianBinaryWriter dataOut = new EndianBinaryWriter(mstream); dataOut.WriteString32(text); dataOut.Close(); message.Content = mstream.ToArray(); }