本文整理汇总了C#中ZXing.Common.BitArray.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# BitArray.ToString方法的具体用法?C# BitArray.ToString怎么用?C# BitArray.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZXing.Common.BitArray
的用法示例。
在下文中一共展示了BitArray.ToString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testAppendKanjiBytes
public void testAppendKanjiBytes()
{
BitArray bits = new BitArray();
Encoder.appendKanjiBytes(shiftJISString(new byte[] { (byte)0x93, 0x5f }), bits);
Assert.AreEqual(" .XX.XX.. XXXXX", bits.ToString());
Encoder.appendKanjiBytes(shiftJISString(new byte[] { (byte)0xe4, (byte)0xaa }), bits);
Assert.AreEqual(" .XX.XX.. XXXXXXX. X.X.X.X. X.", bits.ToString());
}
示例2: testAppendAlphanumericBytes
public void testAppendAlphanumericBytes()
{
// A = 10 = 0xa = 001010 in 6 bits
var bits = new BitArray();
Encoder.appendAlphanumericBytes("A", bits);
Assert.AreEqual(" ..X.X.", bits.ToString());
// AB = 10 * 45 + 11 = 461 = 0x1cd = 00111001101 in 11 bits
bits = new BitArray();
Encoder.appendAlphanumericBytes("AB", bits);
Assert.AreEqual(" ..XXX..X X.X", bits.ToString());
// ABC = "AB" + "C" = 00111001101 + 001100
bits = new BitArray();
Encoder.appendAlphanumericBytes("ABC", bits);
Assert.AreEqual(" ..XXX..X X.X..XX. .", bits.ToString());
// Empty.
bits = new BitArray();
Encoder.appendAlphanumericBytes("", bits);
Assert.AreEqual("", bits.ToString());
// Invalid data.
try
{
Encoder.appendAlphanumericBytes("abc", new BitArray());
}
catch (WriterException)
{
// good
}
}
示例3: testAppend8BitBytes
public void testAppend8BitBytes()
{
// 0x61, 0x62, 0x63
var bits = new BitArray();
Encoder.append8BitBytes("abc", bits, Encoder.DEFAULT_BYTE_MODE_ENCODING);
Assert.AreEqual(" .XX....X .XX...X. .XX...XX", bits.ToString());
// Empty.
bits = new BitArray();
Encoder.append8BitBytes("", bits, Encoder.DEFAULT_BYTE_MODE_ENCODING);
Assert.AreEqual("", bits.ToString());
}
示例4: testTerminateBits
public void testTerminateBits()
{
var v = new BitArray();
Encoder.terminateBits(0, v);
Assert.AreEqual("", v.ToString());
v = new BitArray();
Encoder.terminateBits(1, v);
Assert.AreEqual(" ........", v.ToString());
v = new BitArray();
v.appendBits(0, 3); // Append 000
Encoder.terminateBits(1, v);
Assert.AreEqual(" ........", v.ToString());
v = new BitArray();
v.appendBits(0, 5); // Append 00000
Encoder.terminateBits(1, v);
Assert.AreEqual(" ........", v.ToString());
v = new BitArray();
v.appendBits(0, 8); // Append 00000000
Encoder.terminateBits(1, v);
Assert.AreEqual(" ........", v.ToString());
v = new BitArray();
Encoder.terminateBits(2, v);
Assert.AreEqual(" ........ XXX.XX..", v.ToString());
v = new BitArray();
v.appendBits(0, 1); // Append 0
Encoder.terminateBits(3, v);
Assert.AreEqual(" ........ XXX.XX.. ...X...X", v.ToString());
}
示例5: testAppendNumericBytes
public void testAppendNumericBytes()
{
// 1 = 01 = 0001 in 4 bits.
var bits = new BitArray();
Encoder.appendNumericBytes("1", bits);
Assert.AreEqual(" ...X", bits.ToString());
// 12 = 0xc = 0001100 in 7 bits.
bits = new BitArray();
Encoder.appendNumericBytes("12", bits);
Assert.AreEqual(" ...XX..", bits.ToString());
// 123 = 0x7b = 0001111011 in 10 bits.
bits = new BitArray();
Encoder.appendNumericBytes("123", bits);
Assert.AreEqual(" ...XXXX. XX", bits.ToString());
// 1234 = "123" + "4" = 0001111011 + 0100
bits = new BitArray();
Encoder.appendNumericBytes("1234", bits);
Assert.AreEqual(" ...XXXX. XX.X..", bits.ToString());
// Empty.
bits = new BitArray();
Encoder.appendNumericBytes("", bits);
Assert.AreEqual("", bits.ToString());
}
示例6: testAppendLengthInfo
public void testAppendLengthInfo()
{
var bits = new BitArray();
Encoder.appendLengthInfo(1, // 1 letter (1/1).
Version.getVersionForNumber(1),
Mode.NUMERIC,
bits);
Assert.AreEqual(" ........ .X", bits.ToString()); // 10 bits.
bits = new BitArray();
Encoder.appendLengthInfo(2, // 2 letters (2/1).
Version.getVersionForNumber(10),
Mode.ALPHANUMERIC,
bits);
Assert.AreEqual(" ........ .X.", bits.ToString()); // 11 bits.
bits = new BitArray();
Encoder.appendLengthInfo(255, // 255 letter (255/1).
Version.getVersionForNumber(27),
Mode.BYTE,
bits);
Assert.AreEqual(" ........ XXXXXXXX", bits.ToString()); // 16 bits.
bits = new BitArray();
Encoder.appendLengthInfo(512, // 512 letters (1024/2).
Version.getVersionForNumber(40),
Mode.KANJI,
bits);
Assert.AreEqual(" ..X..... ....", bits.ToString()); // 12 bits.
}
示例7: testAppendBytes
public void testAppendBytes()
{
// Should use appendNumericBytes.
// 1 = 01 = 0001 in 4 bits.
var bits = new BitArray();
Encoder.appendBytes("1", Mode.NUMERIC, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING);
Assert.AreEqual(" ...X", bits.ToString());
// Should use appendAlphanumericBytes.
// A = 10 = 0xa = 001010 in 6 bits
bits = new BitArray();
Encoder.appendBytes("A", Mode.ALPHANUMERIC, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING);
Assert.AreEqual(" ..X.X.", bits.ToString());
// Lower letters such as 'a' cannot be encoded in MODE_ALPHANUMERIC.
try
{
Encoder.appendBytes("a", Mode.ALPHANUMERIC, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING);
}
catch (WriterException)
{
// good
}
// Should use append8BitBytes.
// 0x61, 0x62, 0x63
bits = new BitArray();
Encoder.appendBytes("abc", Mode.BYTE, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING);
Assert.AreEqual(" .XX....X .XX...X. .XX...XX", bits.ToString());
// Anything can be encoded in QRCode.MODE_8BIT_BYTE.
Encoder.appendBytes("\0", Mode.BYTE, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING);
// Should use appendKanjiBytes.
// 0x93, 0x5f
bits = new BitArray();
Encoder.appendBytes(shiftJISString(new byte[] {0x93, 0x5f}), Mode.KANJI, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING);
Assert.AreEqual(" .XX.XX.. XXXXX", bits.ToString());
}
示例8: testAppendModeInfo
public void testAppendModeInfo()
{
BitArray bits = new BitArray();
Encoder.appendModeInfo(Mode.NUMERIC, bits);
Assert.AreEqual(" ...X", bits.ToString());
}
示例9: testMakeTypeInfoInfoBits
public void testMakeTypeInfoInfoBits()
{
// From Appendix C in JISX0510:2004 (p 65)
BitArray bits = new BitArray();
MatrixUtil.makeTypeInfoBits(ErrorCorrectionLevel.M, 5, bits);
Assert.AreEqual(" X......X X..XXX.", bits.ToString());
}
示例10: testMakeVersionInfoBits
public void testMakeVersionInfoBits()
{
// From Appendix D in JISX0510:2004 (p 68)
BitArray bits = new BitArray();
MatrixUtil.makeVersionInfoBits(Version.getVersionForNumber(7), bits);
Assert.AreEqual(" ...XXXXX ..X..X.X ..", bits.ToString());
}
示例11: testToString
public void testToString()
{
BitArray v = new BitArray();
v.appendBits(0xdead, 16); // 1101 1110 1010 1101
Assert.AreEqual(" XX.XXXX. X.X.XX.X", v.ToString());
}
示例12: testAppendBitVector
public void testAppendBitVector()
{
BitArray v1 = new BitArray();
v1.appendBits(0xbe, 8);
BitArray v2 = new BitArray();
v2.appendBits(0xef, 8);
v1.appendBitArray(v2);
// beef = 1011 1110 1110 1111
Assert.AreEqual(" X.XXXXX. XXX.XXXX", v1.ToString());
}