• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# UnicodeEncoding类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UnicodeEncoding的典型用法代码示例。如果您正苦于以下问题:C# UnicodeEncoding类的具体用法?C# UnicodeEncoding怎么用?C# UnicodeEncoding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UnicodeEncoding类属于命名空间,在下文中一共展示了UnicodeEncoding类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;

        UnicodeEncoding expectedValue = new UnicodeEncoding(false,true);
        UnicodeEncoding actualValue;

        TestLibrary.TestFramework.BeginScenario("PosTest1:Create a instance");
        try
        {
            actualValue = new UnicodeEncoding();

            if (!expectedValue.Equals(actualValue))
            {
                TestLibrary.TestFramework.LogError("001", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ")");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:26,代码来源:unicodeencodingctor1.cs


示例2: PosTest1

 public void PosTest1()
 {
     UnicodeEncoding expectedValue = new UnicodeEncoding(false, true);
     UnicodeEncoding actualValue;
     actualValue = new UnicodeEncoding();
     Assert.Equal(expectedValue, actualValue);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:UnicodeEncodingCtor1.cs


示例3: PosTest2

    public bool PosTest2()
    {
        bool retVal = true;

        UnicodeEncoding uE = new UnicodeEncoding(true, true);

        Byte[] expectedValue = new Byte[] { 0xfe,0xff};
        Byte[] actualValue;

        TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the method with bigEndian true and byteOrderMark true.");
        try
        {
            actualValue = uE.GetPreamble();

            if (expectedValue.Equals(actualValue))
            {
                TestLibrary.TestFramework.LogError("003", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ")");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:28,代码来源:unicodeencodinggetpreamble.cs


示例4: toByteArray

    public byte[] toByteArray()
    {
        UnicodeEncoding encoding = new UnicodeEncoding();
        byte[] player_bytes = encoding.GetBytes(player);
        byte[] description_bytes = encoding.GetBytes(description);
        byte[] bytes = new byte[12 + player_bytes.Length + description_bytes.Length + image.Length];

        int array_index = 0;
        KLFCommon.intToBytes(index).CopyTo(bytes, array_index);
        array_index += 4;

        KLFCommon.intToBytes(player_bytes.Length).CopyTo(bytes, array_index);
        array_index += 4;

        player_bytes.CopyTo(bytes, array_index);
        array_index += player_bytes.Length;

        KLFCommon.intToBytes(description_bytes.Length).CopyTo(bytes, array_index);
        array_index += 4;

        description_bytes.CopyTo(bytes, array_index);
        array_index += description_bytes.Length;

        image.CopyTo(bytes, array_index);

        return bytes;
    }
开发者ID:raad287,项目名称:KerbalLiveFeed,代码行数:27,代码来源:Screenshot.cs


示例5: PosTest2

    public bool PosTest2()
    {
        bool retVal = true;

        int expectedValue = 2;
        int actualValue;

        UnicodeEncoding uE = new UnicodeEncoding();

        TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the method and set byteCount as 1.");
        try
        {
            actualValue = uE.GetMaxCharCount(1);

            if (expectedValue != actualValue)
            {
                TestLibrary.TestFramework.LogError("003", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ")");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:28,代码来源:unicodeencodinggetmaxcharcount.cs


示例6: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;

        int expectedValue;
        int actualValue;

        UnicodeEncoding uE1 = new UnicodeEncoding();
        UnicodeEncoding uE2 = new UnicodeEncoding();

        TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the method.");
        try
        {
            expectedValue = uE1.GetHashCode();
            actualValue = uE2.GetHashCode();

            if (expectedValue != actualValue)
            {
                TestLibrary.TestFramework.LogError("001", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ")");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:30,代码来源:unicodeencodinggethashcode.cs


示例7: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;

        UnicodeEncoding uEncoding = new UnicodeEncoding();

        int expectedValue = 0;
        int actualValue;

        TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the method with a empty String.");
        try
        {
            actualValue = uEncoding.GetByteCount("");

            if (expectedValue != actualValue)
            {
                TestLibrary.TestFramework.LogError("001", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ")");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:28,代码来源:unicodeencodinggetbytecount2.cs


示例8: PosTest2

    public bool PosTest2()
    {
        bool retVal = true;

        UnicodeEncoding uEncoding1 = new UnicodeEncoding();
        UnicodeEncoding uEncoding2 = new UnicodeEncoding(false, false);

        bool expectedValue = false;
        bool actualValue;

        TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the method with two instance that not equal.");
        try
        {
            actualValue = uEncoding1.Equals(uEncoding2);

            if (expectedValue != actualValue)
            {
                TestLibrary.TestFramework.LogError("003", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ")");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:29,代码来源:unicodeencodingequals.cs


示例9: VerifyUnicodeEncoding

        public static void VerifyUnicodeEncoding(UnicodeEncoding encoding, bool bigEndian, bool byteOrderMark, bool throwOnInvalidBytes)
        {
            if (byteOrderMark)
            {
                if (bigEndian)
                {
                    Assert.Equal(new byte[] { 0xfe, 0xff }, encoding.GetPreamble());
                }
                else
                {
                    Assert.Equal(new byte[] { 0xff, 0xfe }, encoding.GetPreamble());
                }
            }
            else
            {
                Assert.Empty(encoding.GetPreamble());
            }

            if (throwOnInvalidBytes)
            {
                Assert.Equal(EncoderFallback.ExceptionFallback, encoding.EncoderFallback);
                Assert.Equal(DecoderFallback.ExceptionFallback, encoding.DecoderFallback);
            }
            else
            {
                Assert.Equal(new EncoderReplacementFallback("\uFFFD"), encoding.EncoderFallback);
                Assert.Equal(new DecoderReplacementFallback("\uFFFD"), encoding.DecoderFallback);
            }
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:29,代码来源:UnicodeEncodingTests.cs


示例10: PosTest3

 public void PosTest3()
 {
     UnicodeEncoding uEncoding = new UnicodeEncoding();
     bool actualValue;
     actualValue = uEncoding.Equals(new TimeSpan());
     Assert.False(actualValue);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:7,代码来源:UnicodeEncodingEquals.cs


示例11: PosTest1

 public void PosTest1()
 {
     UnicodeEncoding uEncoding = new UnicodeEncoding();
     int actualValue;
     actualValue = uEncoding.GetByteCount("");
     Assert.Equal(0, actualValue);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:7,代码来源:UnicodeEncodingGetByteCount2.cs


示例12: PosTest1

 public void PosTest1()
 {
     Char[] chars = new Char[] { };
     UnicodeEncoding uEncoding = new UnicodeEncoding();
     int actualValue;
     actualValue = uEncoding.GetByteCount(chars, 0, 0);
     Assert.Equal(0, actualValue);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:8,代码来源:UnicodeEncodingGetByteCount1.cs


示例13: PosTest2

 public void PosTest2()
 {
     UnicodeEncoding uEncoding1 = new UnicodeEncoding();
     UnicodeEncoding uEncoding2 = new UnicodeEncoding(false, false);
     bool actualValue;
     actualValue = uEncoding1.Equals(uEncoding2);
     Assert.False(actualValue);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:8,代码来源:UnicodeEncodingEquals.cs


示例14: PosTest3

 public void PosTest3()
 {
     String str = GetString(1);
     UnicodeEncoding uEncoding = new UnicodeEncoding();
     int actualValue;
     actualValue = uEncoding.GetByteCount(str);
     Assert.Equal(2, actualValue);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:8,代码来源:UnicodeEncodingGetByteCount2.cs


示例15: Ctor_Bool_Bool

        public void Ctor_Bool_Bool(bool bigEndian, bool byteOrderMark)
        {
            UnicodeEncoding encoding = new UnicodeEncoding(bigEndian, byteOrderMark);
            VerifyUnicodeEncoding(encoding, bigEndian, byteOrderMark, throwOnInvalidBytes: false);

            Ctor_Bool_Bool_Bool(bigEndian, byteOrderMark, throwOnInvalidBytes: true);
            Ctor_Bool_Bool_Bool(bigEndian, byteOrderMark, throwOnInvalidBytes: false);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:8,代码来源:UnicodeEncodingTests.cs


示例16: PosTest3

 public void PosTest3()
 {
     Char[] chars = GetCharArray(10);
     Byte[] bytes = new Byte[20];
     UnicodeEncoding uEncoding = new UnicodeEncoding();
     int actualValue;
     actualValue = uEncoding.GetBytes(chars, 0, 0, bytes, 20);
     Assert.Equal(0, actualValue);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:UnicodeEncodingGetBytes1.cs


示例17: PosTest3

        public void PosTest3()
        {
            UnicodeEncoding uE = new UnicodeEncoding(false, true);
            Byte[] expectedValue = new Byte[] { 0xff, 0xfe };
            Byte[] actualValue;

            actualValue = uE.GetPreamble();
            Assert.Equal(expectedValue, actualValue);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:UnicodeEncodingGetPreamble.cs


示例18: PosTest2

        public void PosTest2()
        {
            int expectedValue = 2;
            int actualValue;
            UnicodeEncoding uE = new UnicodeEncoding();

            actualValue = uE.GetMaxCharCount(1);
            Assert.Equal(expectedValue, actualValue);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:UnicodeEncodingGetMaxCharCount.cs


示例19: PosTest3

        public void PosTest3()
        {
            Char[] chars = GetCharArray(1);
            UnicodeEncoding uEncoding = new UnicodeEncoding();
            int actualValue;

            actualValue = uEncoding.GetByteCount(chars, 0, 1);
            Assert.Equal(2, actualValue);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:UnicodeEncodingGetByteCount1.cs


示例20: NegTest1

 public void NegTest1()
 {
     UnicodeEncoding uEncoding = new UnicodeEncoding();
     int actualValue;
     Assert.Throws<ArgumentNullException>(() =>
     {
         actualValue = uEncoding.GetByteCount(null, 0, 0);
     });
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:UnicodeEncodingGetByteCount1.cs



注:本文中的UnicodeEncoding类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Union类代码示例发布时间:2022-05-24
下一篇:
C# UnicodeCategory类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap