Link to home
Start Free TrialLog in
Avatar of DJ_AM_Juicebox
DJ_AM_Juicebox

asked on

Remove non-ascii chars from a String?

Hi,

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.

Thanks
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

I suppose it depends on how you're defining 'ascii' and what your original encoding
ASKER CERTIFIED SOLUTION
Avatar of Hegemon
Hegemon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>it is not an ascii symbol

What is an 'ascii symbol'? Is ' €' one?