Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/forth/lib/string.fs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/openbios-devel/forth/lib/string.fs b/openbios-devel/forth/lib/string.fs index eb64749..43eca1c 100644 --- a/openbios-devel/forth/lib/string.fs +++ b/openbios-devel/forth/lib/string.fs @@ -125,3 +125,22 @@ : parse-hex ( str len -- value ) base @ hex -rot $number if 0 then swap base ! ; + + +\ ----------------------------------------------------- +\ miscellaneous functions +\ ----------------------------------------------------- + +: rot13 ( c - c ) + dup upc [char] A [char] M between if d# 13 + exit then + dup upc [char] N [char] Z between if d# 13 - then +; + +: $rot13 ( str len -- ) + bounds ?do i c@ rot13 i c! loop +; + +: rot13-str ( str len -- newstr len ) + \ Encode copy of input string + strdup 2dup $rot13 +;