diff --git a/vlib/encoding/csv/writer.v b/vlib/encoding/csv/writer.v index bff55bb0eb..4491f89194 100644 --- a/vlib/encoding/csv/writer.v +++ b/vlib/encoding/csv/writer.v @@ -29,33 +29,33 @@ pub fn (mut w Writer) write(record []string) ?bool { for n, field_ in record { mut field := field_ if n > 0 { - w.sb.write(w.delimiter.ascii_str()) + w.sb.write_string(w.delimiter.ascii_str()) } if !w.field_needs_quotes(field) { - w.sb.write(field) + w.sb.write_string(field) continue } - w.sb.write('"') + w.sb.write_string('"') for field.len > 0 { mut i := field.index_any('"\r\n') if i < 0 { i = field.len } - w.sb.write(field[..i]) + w.sb.write_string(field[..i]) field = field[i..] if field.len > 0 { z := field[0] match z { - `"` { w.sb.write('""') } - `\r`, `\n` { w.sb.write(le) } + `"` { w.sb.write_string('""') } + `\r`, `\n` { w.sb.write_string(le) } else {} } field = field[1..] } } - w.sb.write('"') + w.sb.write_string('"') } - w.sb.write(le) + w.sb.write_string(le) return true } diff --git a/vlib/strings/builder.v b/vlib/strings/builder.v index ccffa4ec8f..54c08fbbd9 100644 --- a/vlib/strings/builder.v +++ b/vlib/strings/builder.v @@ -37,9 +37,11 @@ pub fn (mut b Builder) write_b(data byte) { b.len++ } -[deprecated: 'write(string) will be changed to write([]byte)'] -pub fn (mut b Builder) write(s string) { - b.write_string(s) +// write implements the Writer interface +pub fn (mut b Builder) write(data []byte) ?int { + b.buf << data + b.len += data.len + return data.len } // write appends the string `s` to the buffer