當前位置: 首頁>>代碼示例>>C#>>正文


C# BitArray.ToString方法代碼示例

本文整理匯總了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());
 }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:8,代碼來源:EncoderTestCase.cs

示例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
    }
 }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:28,代碼來源:EncoderTestCase.cs

示例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());
 }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:11,代碼來源:EncoderTestCase.cs

示例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());
 }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:28,代碼來源:EncoderTestCase.cs

示例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());
 }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:23,代碼來源:EncoderTestCase.cs

示例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.
 }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:27,代碼來源:EncoderTestCase.cs

示例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());
 }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:34,代碼來源:EncoderTestCase.cs

示例8: testAppendModeInfo

 public void testAppendModeInfo()
 {
    BitArray bits = new BitArray();
    Encoder.appendModeInfo(Mode.NUMERIC, bits);
    Assert.AreEqual(" ...X", bits.ToString());
 }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:6,代碼來源:EncoderTestCase.cs

示例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());
 }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:7,代碼來源:MatrixUtilTestCase.cs

示例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());
 }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:7,代碼來源:MatrixUtilTestCase.cs

示例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());
 }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:6,代碼來源:BitVectorTestCase.cs

示例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());
 }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:10,代碼來源:BitVectorTestCase.cs


注:本文中的ZXing.Common.BitArray.ToString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。