本文整理汇总了C#中UTF7Encoding.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# UTF7Encoding.GetBytes方法的具体用法?C# UTF7Encoding.GetBytes怎么用?C# UTF7Encoding.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTF7Encoding
的用法示例。
在下文中一共展示了UTF7Encoding.GetBytes方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PosTest1
public void PosTest1()
{
Byte[] bytes;
String chars = "UTF7 Encoding Example";
UTF7Encoding UTF7 = new UTF7Encoding();
int byteCount = chars.Length;
bytes = new Byte[byteCount];
int bytesEncodedCount = UTF7.GetBytes(chars, 1, 2, bytes, 0);
}
示例2: VerifyUtf7Encoding
public static void VerifyUtf7Encoding(UTF7Encoding encoding, bool allowOptionals)
{
Assert.Empty(encoding.GetPreamble());
Assert.Equal(new EncoderReplacementFallback(string.Empty), encoding.EncoderFallback);
Assert.Equal(1, encoding.DecoderFallback.MaxCharCount);
Assert.Equal(984, encoding.DecoderFallback.GetHashCode());
if (allowOptionals)
{
Assert.Equal(new byte[] { 33 }, encoding.GetBytes("!"));
}
else
{
Assert.Equal(new byte[] { 43, 65, 67, 69, 45 }, encoding.GetBytes("!"));
}
}
示例3: PosTest2
public void PosTest2()
{
Byte[] bytes;
String chars = "";
UTF7Encoding UTF7 = new UTF7Encoding();
int byteCount = chars.Length;
bytes = new Byte[byteCount];
int bytesEncodedCount = UTF7.GetBytes(chars, 0, byteCount, bytes, 0);
Assert.Equal(0, bytesEncodedCount);
}
示例4: PosTest2
public void PosTest2()
{
Byte[] bytes;
Char[] chars = new Char[] { };
UTF7Encoding UTF7 = new UTF7Encoding();
int byteCount = UTF7.GetByteCount(chars, 0, 0);
bytes = new Byte[byteCount];
int bytesEncodedCount = UTF7.GetBytes(chars, 0, 0, bytes, 0);
Assert.Equal(0, bytesEncodedCount);
}
示例5: NegTest2
public void NegTest2()
{
Byte[] bytes;
String chars = "UTF7 Encoding Example";
UTF7Encoding UTF7 = new UTF7Encoding();
bytes = null;
Assert.Throws<ArgumentNullException>(() =>
{
int bytesEncodedCount = UTF7.GetBytes(chars, 1, 2, bytes, 0);
});
}
示例6: NegTest3
public void NegTest3()
{
Byte[] bytes;
String chars = "UTF7 Encoding Example";
UTF7Encoding UTF7 = new UTF7Encoding();
int byteCount = chars.Length;
bytes = new Byte[byteCount];
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
int bytesEncodedCount = UTF7.GetBytes(chars, -1, 2, bytes, 0);
});
}
示例7: NegTest1
public void NegTest1()
{
Byte[] bytes;
String chars = null;
UTF7Encoding UTF7 = new UTF7Encoding();
int byteCount = 10;
bytes = new Byte[byteCount];
Assert.Throws<ArgumentNullException>(() =>
{
int bytesEncodedCount = UTF7.GetBytes(chars, 1, 2, bytes, 0);
});
}
示例8: PosTest1
public void PosTest1()
{
Byte[] bytes;
Char[] chars = new Char[] {
'\u0023',
'\u0025',
'\u03a0',
'\u03a3' };
UTF7Encoding UTF7 = new UTF7Encoding();
int byteCount = UTF7.GetByteCount(chars, 1, 2);
bytes = new Byte[byteCount];
int bytesEncodedCount = UTF7.GetBytes(chars, 1, 2, bytes, 0);
}
示例9: NegTest2
public void NegTest2()
{
Byte[] bytes;
Char[] chars = new Char[] {
'\u0023',
'\u0025',
'\u03a0',
'\u03a3' };
UTF7Encoding UTF7 = new UTF7Encoding();
int byteCount = UTF7.GetByteCount(chars, 1, 2);
bytes = null;
Assert.Throws<ArgumentNullException>(() =>
{
int bytesEncodedCount = UTF7.GetBytes(chars, 1, 2, bytes, 0);
});
}
示例10: NegTest8
public void NegTest8()
{
Byte[] bytes;
Char[] chars = new Char[] {
'\u0023',
'\u0025',
'\u03a0',
'\u03a3' };
UTF7Encoding UTF7 = new UTF7Encoding();
int byteCount = UTF7.GetByteCount(chars, 1, 2);
bytes = new Byte[byteCount];
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
int bytesEncodedCount = UTF7.GetBytes(chars, chars.Length, 2, bytes, 1);
});
}