本文整理汇总了C#中UnicodeEncoding.GetEncoder方法的典型用法代码示例。如果您正苦于以下问题:C# UnicodeEncoding.GetEncoder方法的具体用法?C# UnicodeEncoding.GetEncoder怎么用?C# UnicodeEncoding.GetEncoder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeEncoding
的用法示例。
在下文中一共展示了UnicodeEncoding.GetEncoder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PosTest1
public void PosTest1()
{
Char[] Chars = GetCharArray(10);
Byte[] bytes = new Byte[20];
Byte[] desBytes = new Byte[20];
int buffer;
int outChars;
bool completed;
UnicodeEncoding uEncoding = new UnicodeEncoding();
int byteCount = uEncoding.GetBytes(Chars, 0, 10, bytes, 0);
bool expectedValue = true;
bool actualValue = true;
Encoder eC = uEncoding.GetEncoder();
eC.Convert(Chars, 0, 10, desBytes, 0, 20, true, out buffer, out outChars, out completed);
if (completed)
{
for (int i = 0; i < 20; i++)
{
actualValue = actualValue & (bytes[i] == desBytes[i]);
}
}
Assert.Equal(expectedValue, actualValue);
}
示例2: PosTest1
public bool PosTest1()
{
bool retVal = true;
Char[] Chars = GetCharArray(10);
Byte[] bytes = new Byte[20];
Byte[] desBytes = new Byte[20];
int buffer;
int outChars;
bool completed;
UnicodeEncoding uEncoding = new UnicodeEncoding();
int byteCount = uEncoding.GetBytes(Chars, 0, 10, bytes, 0);
bool expectedValue = true;
bool actualValue = true;
TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the method");
try
{
Encoder eC = uEncoding.GetEncoder();
eC.Convert(Chars, 0, 10, desBytes, 0, 20, true, out buffer, out outChars, out completed);
if (completed)
{
for (int i = 0; i < 20; i++)
{
actualValue = actualValue & (bytes[i] == desBytes[i]);
}
}
if (expectedValue != actualValue)
{
TestLibrary.TestFramework.LogError("001", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ")" + " when chars is :" + ToString(Chars));
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002", "Unexpected exception:" + e + " when chars is :" + ToString(Chars));
retVal = false;
}
return retVal;
}