Java: check if a String contains only ASCII

import java.nio.charset.Charset;

public boolean isAscii(String v) {
    Charset.forName("US-ASCII").newEncoder().canEncode(v);
}

No comments:

Post a Comment