MCPcopy Create free account
hub / github.com/WICG/webpackage / EncodeByteString

Method EncodeByteString

go/internal/cbor/encoder.go:100–113  ·  view source on GitHub ↗
(bs []byte)

Source from the content-addressed store, hash-verified

98}
99
100func (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
115func (e *Encoder) EncodeTextString(s string) error {
116 // Major type 3: a text string, specifically a string of Unicode

Callers 15

CborBytesMethod · 0.95
TestEncodeByteStringFunction · 0.95
addResponseMethod · 0.95
writeSectionOffsetsFunction · 0.95
writeFooterFunction · 0.95
cborBytesMethod · 0.80
cborBytesMethod · 0.80
EncodeHeaderMethod · 0.80
FinalizeMethod · 0.80
newSignaturesSectionFunction · 0.80
EncodeMethod · 0.80

Calls 1

encodeBytesMethod · 0.95

Tested by 2

TestEncodeByteStringFunction · 0.76