String flushes any pending output from the encoder and returns the encoded string. The Encoder is reset to its initial state so it can be reused.
()
| 72 | // String flushes any pending output from the encoder and returns the encoded |
| 73 | // string. The Encoder is reset to its initial state so it can be reused. |
| 74 | func (e *Encoder) String() (s string) { |
| 75 | // If there's anything left in the buffer, flush it out. |
| 76 | if e.nbuf > 0 { |
| 77 | e.enc.Encode(e.out[:], e.buf[:e.nbuf]) |
| 78 | _, _ = e.sb.Write(e.out[:e.enc.EncodedLen(int(e.nbuf))]) |
| 79 | e.nbuf = 0 |
| 80 | } |
| 81 | s = e.sb.String() |
| 82 | e.Init(e.enc) |
| 83 | return s |
| 84 | } |