Java ASCII Check isContainsNonAscii(String string)

Here you can find the source of isContainsNonAscii(String string)

Description

Checks each char in a string to see if the string contains any char values greater than those used in ASCII.

License

Open Source License

Parameter

Parameter Description
string String to search for Non-ASCII chars.

Declaration

public static boolean isContainsNonAscii(String string) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.Normalizer;

public class Main {
    /** Checks each char in a string to see if the string contains
     * any char values greater than those used in ASCII.
     * @param string  String to search for Non-ASCII chars.
     * @returns  True if any char is greater than u007f, false otherwise
     *///ww w  . j  a v a2 s  .co  m
    public static boolean isContainsNonAscii(String string) {
        string = Normalizer.normalize(string, Normalizer.Form.NFD);
        for (char c : string.toCharArray()) {
            if (c >= '\u007F') {
                return true;
            }
        }
        return false;
    }
}