WriteRune appends the UTF-8 encoding of Unicode code point r to the buffer, returning its length and an error, which is always nil but is included to match bufio.Writer's WriteRune. The buffer is grown as needed; if it becomes too large, WriteRune will panic with ErrTooLarge.
(r rune)
| 288 | // included to match bufio.Writer's WriteRune. The buffer is grown as needed; |
| 289 | // if it becomes too large, WriteRune will panic with ErrTooLarge. |
| 290 | func (b *Buffer) WriteRune(r rune) (n int, err error) { |
| 291 | if r < utf8.RuneSelf { |
| 292 | b.WriteByte(byte(r)) |
| 293 | return 1, nil |
| 294 | } |
| 295 | n = utf8.EncodeRune(b.runeBytes[0:], r) |
| 296 | b.Write(b.runeBytes[0:n]) |
| 297 | return n, nil |
| 298 | } |
| 299 | |
| 300 | // Read reads the next len(p) bytes from the buffer or until the buffer |
| 301 | // is drained. The return value n is the number of bytes read. If the |