| 98 | } |
| 99 | |
| 100 | func (e *Encoder) EncodeByteString(bs []byte) error { |
| 101 | // Major type 2: a byte string. The string's length in bytes is |
| 102 | // represented following the rules for positive integers (major type |
| 103 | // 0). For example, a byte string whose length is 5 would have an |
| 104 | // initial byte of 0b010_00101 (major type 2, additional information |
| 105 | // 5 for the length), followed by 5 bytes of binary content. A byte |
| 106 | // string whose length is 500 would have 3 initial bytes of |
| 107 | // 0b010_11001 (major type 2, additional information 25 to indicate a |
| 108 | // two-byte length) followed by the two bytes 0x01f4 for a length of |
| 109 | // 500, followed by 500 bytes of binary content. |
| 110 | // |
| 111 | // https://tools.ietf.org/html/rfc7049#section-2.1 |
| 112 | return e.encodeBytes(TypeBytes, bs) |
| 113 | } |
| 114 | |
| 115 | func (e *Encoder) EncodeTextString(s string) error { |
| 116 | // Major type 3: a text string, specifically a string of Unicode |