本文整理汇总了C#中UnicodeEncoding.Convert方法的典型用法代码示例。如果您正苦于以下问题:C# UnicodeEncoding.Convert方法的具体用法?C# UnicodeEncoding.Convert怎么用?C# UnicodeEncoding.Convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeEncoding
的用法示例。
在下文中一共展示了UnicodeEncoding.Convert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDecoder
public void GetDecoder()
{
char[] sourceChars = "abc\u1234\uD800\uDC00defg".ToCharArray();
char[] destinationChars = new char[10];
byte[] bytes = new UnicodeEncoding().GetBytes(sourceChars);
int bytesUsed;
int charsUsed;
bool completed;
Decoder decoder = new UnicodeEncoding().GetDecoder();
decoder.Convert(bytes, 0, 20, destinationChars, 0, 10, true, out bytesUsed, out charsUsed, out completed);
if (completed)
{
Assert.Equal(sourceChars, destinationChars);
}
}
示例2: GetEncoder
public void GetEncoder()
{
char[] chars = "abc\u1234\uD800\uDC00defg".ToCharArray();
byte[] bytes = new UnicodeEncoding().GetBytes(chars);
byte[] desBytes = new byte[20];
int buffer;
int outChars;
bool completed;
Encoder encoder = new UnicodeEncoding().GetEncoder();
encoder.Convert(chars, 0, 10, desBytes, 0, 20, true, out buffer, out outChars, out completed);
if (completed)
{
Assert.Equal(bytes, desBytes);
}
}
示例3: GetEncoder
public void GetEncoder()
{
char[] chars = EncodingHelpers.GetRandomString(10).ToCharArray();
byte[] bytes = new UnicodeEncoding().GetBytes(chars);
byte[] desBytes = new byte[20];
int buffer;
int outChars;
bool completed;
Encoder encoder = new UnicodeEncoding().GetEncoder();
encoder.Convert(chars, 0, 10, desBytes, 0, 20, true, out buffer, out outChars, out completed);
if (completed)
{
Assert.Equal(bytes, desBytes);
}
}