DROP function IF EXISTS mysql_replaceallnonprintablecharacters;
CREATE function mysql_replaceallnonprintablecharacters (data VARCHAR(1024))
returns VARCHAR(1024)
begin
DECLARE i INT DEFAULT 0;
DECLARE finaldata VARCHAR(1024) DEFAULT '';
SET FINALDATA:=data;
WHILE i < 31 do
SET FINALDATA:=REPLACE(finaldata, CHAR(i), '');
SET i := i+1;
end WHILE;
RETURN finaldata;
end