Skip to content

Commit 688053b

Browse files
committed
Fix text length for UTF-8
1 parent 7ff330e commit 688053b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

googletts/option.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package googletts
33
import (
44
"errors"
55
"strconv"
6+
"unicode/utf8"
67
)
78

89
// Option contains optional parameters for Google TTS API.
@@ -53,7 +54,7 @@ func (o Option) getTextLength() string {
5354
if o.TextLength > 0 {
5455
return strconv.Itoa(o.TextLength)
5556
}
56-
return strconv.Itoa(len(o.Text))
57+
return strconv.Itoa(utf8.RuneCountInString(o.Text))
5758
}
5859

5960
func (o Option) getToken() string {

0 commit comments

Comments
 (0)