本文整理汇总了C#中UnicodeEncoding类的典型用法代码示例。如果您正苦于以下问题:C# UnicodeEncoding类的具体用法?C# UnicodeEncoding怎么用?C# UnicodeEncoding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnicodeEncoding类属于命名空间,在下文中一共展示了UnicodeEncoding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: PosTest1
public void PosTest1()
{
UnicodeEncoding expectedValue = new UnicodeEncoding(false, true);
UnicodeEncoding actualValue;
actualValue = new UnicodeEncoding();
Assert.Equal(expectedValue, actualValue);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例10: PosTest3
public void PosTest3()
{
UnicodeEncoding uEncoding = new UnicodeEncoding();
bool actualValue;
actualValue = uEncoding.Equals(new TimeSpan());
Assert.False(actualValue);
}
示例11: PosTest1
public void PosTest1()
{
UnicodeEncoding uEncoding = new UnicodeEncoding();
int actualValue;
actualValue = uEncoding.GetByteCount("");
Assert.Equal(0, actualValue);
}
示例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);
}
示例13: PosTest2
public void PosTest2()
{
UnicodeEncoding uEncoding1 = new UnicodeEncoding();
UnicodeEncoding uEncoding2 = new UnicodeEncoding(false, false);
bool actualValue;
actualValue = uEncoding1.Equals(uEncoding2);
Assert.False(actualValue);
}
示例14: PosTest3
public void PosTest3()
{
String str = GetString(1);
UnicodeEncoding uEncoding = new UnicodeEncoding();
int actualValue;
actualValue = uEncoding.GetByteCount(str);
Assert.Equal(2, actualValue);
}
示例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);
}