See ISO 18004:2006, 6.4.1, Tables 2 and 3. This enum encapsulates the various modes in which data can be encoded to bits in the QR code standard.

Example #1
0
 /// <summary>
 /// Append "bytes" in "mode" mode (encoding) into "bits". On success, store the result in "bits".
 /// </summary>
 /// <param name="content">The content.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="bits">The bits.</param>
 /// <param name="encoding">The encoding.</param>
 internal static void appendBytes(String content,
                         Mode mode,
                         BitArray bits,
                         String encoding)
 {
    if (mode.Equals(Mode.NUMERIC))
       appendNumericBytes(content, bits);
    else
       if (mode.Equals(Mode.ALPHANUMERIC))
          appendAlphanumericBytes(content, bits);
       else
          if (mode.Equals(Mode.BYTE))
             append8BitBytes(content, bits, encoding);
          else
             if (mode.Equals(Mode.KANJI))
                appendKanjiBytes(content, bits);
             else
                throw new WriterException("Invalid mode: " + mode);
 }
Example #2
0
 /// <summary>
 /// Append length info. On success, store the result in "bits".
 /// </summary>
 /// <param name="numLetters">The num letters.</param>
 /// <param name="version">The version.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="bits">The bits.</param>
 internal static void appendLengthInfo(int numLetters, Version version, Mode mode, BitArray bits)
 {
    int numBits = mode.getCharacterCountBits(version);
    if (numLetters >= (1 << numBits))
    {
       throw new WriterException(numLetters + " is bigger than " + ((1 << numBits) - 1));
    }
    bits.appendBits(numLetters, numBits);
 }
Example #3
0
 /// <summary>
 /// Append "bytes" in "mode" mode (encoding) into "bits". On success, store the result in "bits".
 /// </summary>
 /// <param name="content">The content.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="bits">The bits.</param>
 /// <param name="encoding">The encoding.</param>
 internal static void appendBytes(String content,
                       Mode mode,
                       BitArray bits,
                       String encoding)
 {
     // TODO: check the purpose of this .Equals(obj)
     if (mode == Mode.BYTE)
     append8BitBytes(content, bits, encoding);
     else
         throw new WriterException("Invalid mode: " + mode);
 }
Example #4
0
 /// <summary>
 /// Append mode info. On success, store the result in "bits".
 /// </summary>
 /// <param name="mode">The mode.</param>
 /// <param name="bits">The bits.</param>
 internal static void appendModeInfo(Mode mode, BitArray bits)
 {
    bits.appendBits(mode.Bits, 4);
 }
Example #5
0
 /// <summary>
 /// Append "bytes" in "mode" mode (encoding) into "bits". On success, store the result in "bits".
 /// </summary>
 /// <param name="content">The content.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="bits">The bits.</param>
 /// <param name="encoding">The encoding.</param>
 internal static void appendBytes(String content,
                         Mode mode,
                         BitArray bits,
                         String encoding)
 {
   if (mode.Equals(Mode.BYTE))
       append8BitBytes(content, bits, encoding);
       else
           throw new WriterException("Invalid mode: " + mode);
 }