3
Well, from my own experience, I'd say there's already something like that.
Correct me if I'm wrong, but if you need to use Text input from the client, you're likely to store it somewhere. If you store it in an Object class instance, extending XoopsObject, you can use the setVar() getVar() methods to have this clean up made for you, somehow.
Otherwise, depending on your usage, you can have a look at the TextSanitizer class.