This commit is contained in:
GO
2021-09-07 19:55:43 +00:00
parent 354983d93f
commit b0a83f934e
4 changed files with 68 additions and 2 deletions

View File

@ -0,0 +1,12 @@
// Package morestrings implements additional functions to manipulate UTF-8
// encoded strings, beyond what is provided in the standard "strings" package.
package morestrings
// ReverseRunes returns its argument string reversed rune-wise left to right.
func ReverseRunes(s string) string {
r := []rune(s)
for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
r[i], r[j] = r[j], r[i]
}
return string(r)
}