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

Content added Content deleted
m ({{omit from|Openscad}})
No edit summary
Line 213: Line 213:


[[Category:String manipulation]]
[[Category:String manipulation]]

=={{header|Liberty BASIC}}==
<lang lb>
all$ =""
for i =0 to 255
all$ =all$ +chr$( i)
next i

print "Original string of bytes. ( chr$( 10) causes a CRLF.)"
print all$
print

lessControl$ =controlStripped$( all$)
print "With control codes stripped out."
print lessControl$
print

lessExtendedAndControl$ =extendedStripped$( lessControl$)
print "With extended codes stripped out too."
print lessExtendedAndControl$

end

function controlStripped$( i$)
r$ =""
for j =1 to len( i$)
ch$ =mid$( i$, j, 1)
if asc( ch$) >=32 then r$ =r$ +ch$
next j
controlStripped$ =r$
end function

function extendedStripped$( i$)
r$ =""
for j =1 to len( i$)
ch$ =mid$( i$, j, 1)
if asc( ch$) <=128 then r$ =r$ +ch$
next j
extendedStripped$ =r$
end function
</lang>
=={{header|Lua}}==
=={{header|Lua}}==
<lang lua>function Strip_Control_Codes( str )
<lang lua>function Strip_Control_Codes( str )