WriteByte emits a single byte.
(s byte)
| 151 | |
| 152 | // WriteByte emits a single byte. |
| 153 | func (b *Buffer) WriteByte(s byte) error { |
| 154 | b.startWrite() |
| 155 | if b.mode == UnsafeEscaped && |
| 156 | (s >= utf8.RuneSelf || |
| 157 | s == m.StartS[0] || s == m.EndS[0]) { |
| 158 | // Unsafe byte. Escape it. |
| 159 | _, err := b.WriteString(m.EscapeMarkS) |
| 160 | return err |
| 161 | } |
| 162 | m, ok := b.tryGrowByReslice(1) |
| 163 | if !ok { |
| 164 | m = b.grow(1) |
| 165 | } |
| 166 | b.buf[m] = s |
| 167 | return nil |
| 168 | } |
| 169 | |
| 170 | // WriteRune emits a single rune. |
| 171 | func (b *Buffer) WriteRune(s rune) error { |