in reply to remove bad characters

If the previous replies didn't help, you'll need to be more clear about what you consider to be "bad characters", and what falls within your range of "plain text" (this can mean different things to different people).

If you know anything at all about the character encoding(s) that you are dealing with (what do you have as input, what do you want as output), that information could be relevant for picking a good solution, too.

Oh, and: What have you tried, and how did it fall short of what you really wanted? Show us some sample data and some code, so we can see where you are.