|
Validating ASCII character set
In this post, I will write about how to validate characters of ASCII characterset.
ASCII is a well know character set. It is a 7 bit character set and represents 128 characters. The printable character codes range from 33 to 126 inclusive. Sometimes you want to make sure that your strings do not contains non ASCII printable character. This is easy and can be done by writing a method for this.
Review the static method below. It takes an ArrayList of String type and after removing the non ASCII and non printable characters, it return the updated ArrayList. All the non printable and non ASCII characters are replaced by null.
<div class="wp_syntax"><div class="code"> public static ArrayList valiateAsciiSet(ArrayList arraylist){ ArrayList tmpList = new ArrayList(); String str = ""; for(int j=0; j < arraylist.size();j++) { str = arraylist.get(j); String resultantString = ""; for(int i=0;i=33 && charCode
|