Strip control codes and extended characters from a string

From Rosetta Code
Revision as of 06:26, 20 February 2021 by Drkameleon (talk | contribs)

Arturo

<lang rebol>str: ---string of ☺☻♥♦⌂, may include control characters and other ♫☼§►↔◄░▒▓█┌┴┐±÷²¬└┬┘ilk.---

print "with extended characters" print join select split str 'x ->

   not? in? to :integer to :char x (0..31)++127

print "without extended characters" print join select split str 'x ->

   and? ascii? x
        not? in? to :integer to :char x (0..31)++127</lang>
Output:
with extended characters
string of ☺☻♥♦⌂, may include control characters and other    ♫☼§►↔◄░▒▓█┌┴┐±÷²¬└┬┘ilk.
without extended characters
string of , may include control characters and other    ilk.