本文整理汇总了C#中UnicodeEncoding.GetPreamble方法的典型用法代码示例。如果您正苦于以下问题:C# UnicodeEncoding.GetPreamble方法的具体用法?C# UnicodeEncoding.GetPreamble怎么用?C# UnicodeEncoding.GetPreamble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeEncoding
的用法示例。
在下文中一共展示了UnicodeEncoding.GetPreamble方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: PosTest1
public bool PosTest1()
{
bool retVal = true;
UnicodeEncoding uE = new UnicodeEncoding(true,false);
Byte[] expectedValue = new Byte[] { };
Byte[] actualValue;
TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the method with bigEndian true and byteOrderMark false.");
try
{
actualValue = uE.GetPreamble();
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;
}
示例3: 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);
}
示例4: GetPreamble
public void GetPreamble(bool bigEndian, bool byteOrderMark, byte[] expected)
{
UnicodeEncoding encoding = new UnicodeEncoding(bigEndian, byteOrderMark);
Assert.Equal(expected, encoding.GetPreamble());
}