Anonymous user
Strip control codes and extended characters from a string: Difference between revisions
Strip control codes and extended characters from a string (view source)
Revision as of 16:01, 7 June 2011
, 13 years agoAdded PicoLisp
m (→{{header|J}}) |
(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}}==
|