mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
@@ -700,10 +700,11 @@ reverse :: proc(s: string, allocator := context.allocator) -> string {
|
|||||||
str := s;
|
str := s;
|
||||||
n := len(str);
|
n := len(str);
|
||||||
buf := make([]byte, n);
|
buf := make([]byte, n);
|
||||||
i := 0;
|
i := n;
|
||||||
|
|
||||||
for len(str) > 0 {
|
for len(str) > 0 {
|
||||||
_, w := utf8.decode_rune_in_string(str);
|
_, w := utf8.decode_rune_in_string(str);
|
||||||
|
i -= w;
|
||||||
copy(buf[i:], cast([]byte)str[:w]);
|
copy(buf[i:], cast([]byte)str[:w]);
|
||||||
str = str[w:];
|
str = str[w:];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user