public void TextWithEncoding_ImplicitOperator_1() { TextWithEncoding text = "Hello"; byte[] bytes = text.ToBytes(); Assert.AreEqual(5, bytes.Length); }
public void TextWithEncoding_Construction_3() { TextWithEncoding text = new TextWithEncoding("Hello", true); byte[] bytes = text.ToBytes(); Assert.AreEqual(5, bytes.Length); }
public void TextWithEncoding_Construction_4() { TextWithEncoding text = new TextWithEncoding("Привет", Encoding.GetEncoding(1251)); byte[] bytes = text.ToBytes(); Assert.AreEqual(6, bytes.Length); }
public void TextWithEncoding_Construction_2() { TextWithEncoding text = new TextWithEncoding("Привет"); byte[] bytes = text.ToBytes(); Assert.AreEqual(12, bytes.Length); }
/// <summary> /// Записываем строку в произвольной кодировке. /// </summary> public static Stream EncodeTextWithEncoding ( [NotNull] this Stream stream, [CanBeNull] TextWithEncoding text ) { if (!ReferenceEquals(text, null)) { byte[] bytes = text.ToBytes(); stream.Write(bytes, 0, bytes.Length); } return(stream); }