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, " ")
|
words := strings.Split(status, " ")
|
||||||
s := ""
|
s := ""
|
||||||
for _, word := range words {
|
for _, word := range words {
|
||||||
if s == "" && len(word) <= CHARACTER_LIMIT {
|
asRunes := []rune(word)
|
||||||
|
if s == "" && len(asRunes) <= CHARACTER_LIMIT {
|
||||||
s = word
|
s = word
|
||||||
} else if len(s)+1+len(word) <= CHARACTER_LIMIT {
|
} else if len(s)+1+len(asRunes) <= CHARACTER_LIMIT {
|
||||||
s = s + " " + word
|
s = s + " " + word
|
||||||
} else {
|
} else {
|
||||||
split = append(split, s)
|
split = append(split, s)
|
||||||
bound := goutil.IntMin(len(word), CHARACTER_LIMIT)
|
bound := goutil.IntMin(len(asRunes), CHARACTER_LIMIT)
|
||||||
s = string([]rune(word)[:bound])
|
s = string(asRunes[:bound])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s != "" {
|
if s != "" {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user