core :: String :: filter_nonprintable
'\n'
(LFD) or ' '
(space).assert "hello".filter_nonprintable == "hello"
assert "\r\n\t".filter_nonprintable == "^13\n^9"
# Use a special notation for whitespace characters that are not `'\n'` (LFD) or `' '` (space).
#
# ~~~
# assert "hello".filter_nonprintable == "hello"
# assert "\r\n\t".filter_nonprintable == "^13\n^9"
# ~~~
fun filter_nonprintable: String
do
var buf = new Buffer
for c in self do
var cp = c.code_point
if cp < 32 and c != '\n' then
buf.append "^{cp}"
else
buf.add c
end
end
return buf.to_s
end
src/testing/testing_base.nit:315,2--333,4