split status along runes, not bytes
This commit is contained in:
parent
a3fb358f1c
commit
8f0cb6bd75
|
@ -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 != "" {
|
||||
|
|
Loading…
Reference in New Issue
Block a user