utf8: format utf8_util.v (#10135)
parent
4974fd09e5
commit
a639f94050
|
@ -113,13 +113,13 @@ pub fn raw_index(s string, index int) string {
|
|||
// reverse - returns a reversed string.
|
||||
// example: utf8.reverse('你好世界hello world') => 'dlrow olleh界世好你'.
|
||||
pub fn reverse(s string) string {
|
||||
len_s := utf8.len(s)
|
||||
len_s := len(s)
|
||||
if len_s == 0 || len_s == 1 {
|
||||
return s.clone()
|
||||
}
|
||||
mut str_array := []string{}
|
||||
for i in 0..len_s {
|
||||
str_array << utf8.raw_index(s, i)
|
||||
for i in 0 .. len_s {
|
||||
str_array << raw_index(s, i)
|
||||
}
|
||||
str_array = str_array.reverse()
|
||||
return str_array.join('')
|
||||
|
|
Loading…
Reference in New Issue