Strip control codes and extended characters from a string: Difference between revisions

Added PicoLisp
(Added PicoLisp)
Line 36:
 
[[Category:String manipulation]]
 
=={{header|PicoLisp}}==
Control characters in strings are written with a hat (^) in PicoLisp. ^? is the DEL character.
<lang PicoLisp>(de stripCtrl (Str)
(pack
(filter
'((C)
(nor (= "^?" C) (> " " C "^A")) )
(chop Str) ) ) )
 
(de stripCtrlExt (Str)
(pack
(filter
'((C) (> "^?" C "^_"))
(chop Str) ) ) )</lang>
Test:
<pre>: (char "^?")
-> 127
 
: (char "^_")
-> 31
 
: (stripCtrl "^I^M a b c^? d äöüß")
-> " a b c d äöüß"
 
: (stripCtrlExt "^I^M a b c^? d äöüß")
-> " a b c d "</pre>
 
=={{header|PureBasic}}==
Anonymous user