Remove non-ascii chars from a String?
Posted on 2010-09-24
Is there any java utility for removing non-ascii characters from a string? I think I can loop through each character (charAt()) which will give me its "ascii value" and if it's not in the ascii range, just wipe it. But I'm not sure what charAt() will return when I really have non-ascii characters since I've never run into that situation.
How can I do it?
The reason I need to do it is that I'm using a library which does ellipsiszing of a string, and if it encounters and non-ascii char it seems to crash, so want to clean my strings before passing them in.