コード例 #1
0
        public void ReadAndResetUTF8()
        {               //****************************************
            string MyResult1, MyResult2;

            //****************************************

            using (var Reader = new BinaryTextReader(_TestInput, Encoding.ASCII, true))
            {
                MyResult1 = Reader.ReadToEnd();

                Reader.Reset();

                MyResult2 = Reader.ReadToEnd();
            }

            Assert.AreEqual(_TestOutput, MyResult1);
            Assert.AreEqual(_TestOutput, MyResult2);
        }
コード例 #2
0
        public void ReadToEnd()
        {
            string MyResult;

            using (var Reader = new BinaryTextReader(_TestInput, Encoding.UTF8, false))
            {
                MyResult = Reader.ReadToEnd();
            }

            Assert.AreEqual(_TestOutput, MyResult);
        }
コード例 #3
0
        public void ReadDetectEncodingUTF8()
        {
            string MyResult;

            using (var Reader = new BinaryTextReader(_TestInput, Encoding.ASCII, true))
            {
                MyResult = Reader.ReadToEnd();
            }

            Assert.AreEqual(_TestOutput, MyResult);
        }
コード例 #4
0
        public void ReadASCII()
        {
            string MyResult;
            string TempOutput;

            using (var RawStream = new MemoryStream(_TestInput))
                using (var Reader = new StreamReader(RawStream, Encoding.ASCII, false))
                {
                    TempOutput = Reader.ReadToEnd();
                }

            using (var Reader = new BinaryTextReader(_TestInput, Encoding.ASCII, false))
            {
                MyResult = Reader.ReadToEnd();
            }

            Assert.AreEqual(TempOutput, MyResult);
        }
コード例 #5
0
        public void ReadDetectEncodingUTF8NoBOM()
        {
            string MyResult;

            byte[] TempInput;

            using (var RawStream = new MemoryStream())
            {
                using (var Writer = new StreamWriter(RawStream, new UTF8Encoding(false)))
                {
                    Writer.Write(_TestOutput);
                }

                TempInput = RawStream.ToArray();
            }

            using (var Reader = new BinaryTextReader(TempInput, Encoding.UTF8, true))
            {
                MyResult = Reader.ReadToEnd();
            }

            Assert.AreEqual(_TestOutput, MyResult);
        }
コード例 #6
0
        public void ReadDetectEncodingUnicode([Values(false, true)] bool bigEndian)
        {
            string MyResult;

            byte[] TempInput;

            using (var RawStream = new MemoryStream())
            {
                using (var Writer = new StreamWriter(RawStream, new UnicodeEncoding(bigEndian, true)))
                {
                    Writer.Write(_TestOutput);
                }

                TempInput = RawStream.ToArray();
            }

            using (var Reader = new BinaryTextReader(TempInput, Encoding.ASCII, true))
            {
                MyResult = Reader.ReadToEnd();
            }

            Assert.AreEqual(_TestOutput, MyResult);
        }