public void BigEndianBinaryReaderConstructorEncodingUtf16Test() { byte[] array = new byte[] {0, 0, 0, 6, 97, 00, 98, 00, 99, 00}; using (Stream input = new MemoryStream(array)) { // "abc" string in UTF16LE + prefix int string length in bytes Encoding encoding = Encoding.Unicode; BigEndianBinaryReader target = new BigEndianBinaryReader(new StreamAdapter(input), encoding); string expected = "abc"; string actual = target.ReadString(); Assert.AreEqual(expected, actual); } }
public void ReadStringTest() { byte[] array = new byte[] { 0, 0, 0, 3, 97, 98, 99 }; // 'abc' string in utf-8 + prefix int string length in bytes using (Stream input = new MemoryStream(array)) { BigEndianBinaryReader target = new BigEndianBinaryReader(new StreamAdapter(input)); string expected = "abc"; string actual = target.ReadString(); Assert.AreEqual(expected, actual); } }