utf8: format utf8_util.v (#10135)

pull/10137/head
Enzo 2021-05-19 12:03:43 +02:00 committed by GitHub
parent 4974fd09e5
commit a639f94050
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -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('')