go-guerrilla icon indicating copy to clipboard operation
go-guerrilla copied to clipboard

trimToLimit does not work with utf-8 encoding

Open 4k7 opened this issue 5 years ago • 1 comments

Hi,

trimToLimit function (in file p_guerrilla_db_redis.go) does not work with utf-8 encoding. This function is also used in the file p_sql.go.

It should be like this to correct operation.

func trimToLimit(str string, limit int) string {
	ret := strings.TrimSpace(str)
	if len([]rune(str)) > limit {
		ret = string([]rune(str)[:limit])
	}
	return ret
}

Thanks.

4k7 avatar May 14 '20 16:05 4k7

Thanks!

flashmob avatar May 20 '20 03:05 flashmob