From d5ee06e128b7545644b9f580ceab75fbc1322248 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Thu, 1 Oct 2020 14:46:28 +0200 Subject: [PATCH] fixed unicode chars printed wrong in WriteString --- write_string.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/write_string.go b/write_string.go index aa046b0..dd7412e 100644 --- a/write_string.go +++ b/write_string.go @@ -3,11 +3,13 @@ package buf2d // WriteString writes a whole string to the buffer at position (x,y) // no word wrap is applied at all. If the string does not fit, it will be truncated func (b *Buffer) WriteString(str string, x, y int) { - for dx, r := range str { - if x+dx >= b.width { + dx := x + for _, r := range str { + if dx >= b.width { return } - b.Set(x+dx, y, r) + b.Set(dx, y, r) + dx++ } }