string :str-rev ( string $TEXT )
Returns a reversed version of $TEXT. Note that, if a bare (ASCII) string is passed, all the byte values are swapped, so any multiple-byte encodings will probably break spectacularly. If your text is UTF-8 encoded, consider passing it to this function using the language's utf8 type. This will make the function swap whole codepoints, instead of single bytes.
# :str-rev example :set &str s'' :set &utf u'' :write s'Gibe text plox: ' :readln &txt :set &utf $str :set &revutf :str-rev $utf !if :eq $utf $revutf :writeln szYour text is a palindrome! Ain't that cool?z !fi :writeln s'ascii-reversed: ' :str-rev $str :writeln s'utf8-reversed: ' $revutf
wikistrona zmodyfikowana 2014/0916/1555