MCPcopy Create free account
hub / github.com/tulir/whatsmeow / writeString

Method writeString

binary/encoder.go:135–149  ·  view source on GitHub ↗
(data string)

Source from the content-addressed store, hash-verified

133}
134
135func (w *binaryEncoder) writeString(data string) {
136 var dictIndex byte
137 if tokenIndex, ok := token.IndexOfSingleToken(data); ok {
138 w.pushByte(tokenIndex)
139 } else if dictIndex, tokenIndex, ok = token.IndexOfDoubleByteToken(data); ok {
140 w.pushByte(token.Dictionary0 + dictIndex)
141 w.pushByte(tokenIndex)
142 } else if validateNibble(data) {
143 w.writePackedBytes(data, token.Nibble8)
144 } else if validateHex(data) {
145 w.writePackedBytes(data, token.Hex8)
146 } else {
147 w.writeStringRaw(data)
148 }
149}
150
151func (w *binaryEncoder) writeBytes(value []byte) {
152 w.writeByteLength(len(value))

Callers 4

writeNodeMethod · 0.95
writeMethod · 0.95
writeJIDMethod · 0.95
writeAttributesMethod · 0.95

Calls 7

pushByteMethod · 0.95
writePackedBytesMethod · 0.95
writeStringRawMethod · 0.95
IndexOfSingleTokenFunction · 0.92
IndexOfDoubleByteTokenFunction · 0.92
validateNibbleFunction · 0.85
validateHexFunction · 0.85

Tested by

no test coverage detected