Exemple #1
0
        public void TestCharacterDetection()
        {
            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0x09 }, 0).IsValid);
            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0x0A }, 0).IsValid);
            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0x0D }, 0).IsValid);
            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0x20 }, 0).IsValid);
            Assert.IsFalse(EucJp.IsValidChar(new byte[] { 0x20 }, 0).IsEucJp);

            for (byte i = 0x0E; i < 0x20; i++)
            {
                Assert.IsFalse(EucJp.IsValidChar(new byte[] { i }, 0).IsValid);
            }

            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0x21 }, 0).IsValid);
            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0x7E }, 0).IsValid);
            Assert.IsFalse(EucJp.IsValidChar(new byte[] { 0x7F }, 0).IsValid);
            Assert.IsFalse(EucJp.IsValidChar(new byte[] { 0x7e }, 0).IsEucJp);

            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0x8E, 0xA1 }, 0).IsValid);
            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0x8E, 0xDF }, 0).IsValid);
            Assert.IsFalse(EucJp.IsValidChar(new byte[] { 0x8E, 0xE0 }, 0).IsValid);
            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0x8E, 0xDF }, 0).IsEucJp);

            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0xA1, 0xA1 }, 0).IsValid);
            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0xFE, 0xFE }, 0).IsValid);
            Assert.IsFalse(EucJp.IsValidChar(new byte[] { 0xFF, 0xFE }, 0).IsValid);
            Assert.IsFalse(EucJp.IsValidChar(new byte[] { 0xFE, 0xFF }, 0).IsValid);
            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0xFE, 0xFE }, 0).IsEucJp);

            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0x8F, 0xA1, 0xA1 }, 0).IsValid);
            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0x8F, 0xFE, 0xFE }, 0).IsValid);
            Assert.IsFalse(EucJp.IsValidChar(new byte[] { 0x8F, 0xFF, 0xFF }, 0).IsValid);
            Assert.IsTrue(EucJp.IsValidChar(new byte[] { 0x8F, 0xFE, 0xFE }, 0).IsEucJp);
        }