From 8f0cb6bd756d821ffe3fc8584e1d932075a35575 Mon Sep 17 00:00:00 2001 From: gutmet Date: Mon, 12 Oct 2020 09:18:07 +0200 Subject: [PATCH] split status along runes, not bytes --- drivel.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivel.go b/drivel.go index 067aa7c..7ad2962 100644 --- a/drivel.go +++ b/drivel.go @@ -344,14 +344,15 @@ func splitStatus(status string) []string { words := strings.Split(status, " ") s := "" for _, word := range words { - if s == "" && len(word) <= CHARACTER_LIMIT { + asRunes := []rune(word) + if s == "" && len(asRunes) <= CHARACTER_LIMIT { s = word - } else if len(s)+1+len(word) <= CHARACTER_LIMIT { + } else if len(s)+1+len(asRunes) <= CHARACTER_LIMIT { s = s + " " + word } else { split = append(split, s) - bound := goutil.IntMin(len(word), CHARACTER_LIMIT) - s = string([]rune(word)[:bound]) + bound := goutil.IntMin(len(asRunes), CHARACTER_LIMIT) + s = string(asRunes[:bound]) } } if s != "" {