Java tutorial
//package com.java2s; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; public class Main { public static String stripNonASCII(String ret) { char[] chars = ret.toCharArray(); CharsetDecoder d = Charset.forName("US-ASCII").newDecoder(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < chars.length; i++) { try { char c = chars[i]; String letter = new String(new char[] { c }); byte bytearray[] = letter.getBytes(); CharBuffer r = d.decode(ByteBuffer.wrap(bytearray)); r.toString(); sb.append(c); } catch (CharacterCodingException e) { } } return sb.toString(); } }