WriteStringHeader writes just the string size header of a MessagePack 'str' object. The user is responsible for writing 'sz' more valid UTF-8 bytes to the stream.
(sz uint32)
| 520 | // is responsible for writing 'sz' more valid UTF-8 |
| 521 | // bytes to the stream. |
| 522 | func (mw *Writer) WriteStringHeader(sz uint32) error { |
| 523 | switch { |
| 524 | case sz <= 31: |
| 525 | return mw.push(wfixstr(uint8(sz))) |
| 526 | case sz <= math.MaxUint8: |
| 527 | return mw.prefix8(mstr8, uint8(sz)) |
| 528 | case sz <= math.MaxUint16: |
| 529 | return mw.prefix16(mstr16, uint16(sz)) |
| 530 | default: |
| 531 | return mw.prefix32(mstr32, sz) |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | // WriteStringFromBytes writes a 'str' object |
| 536 | // from a []byte. |