ASCII table

Leave a comment

February 10, 2017 by oneOokay

来仔细看一眼ASCII table:以decimal来看

总共有256个,包含

control character : 33个, 从0-31 加上127(del)

printable character:95个,从32-126。其中:

  • 0-9: 48-57
  • A-Z:65-90
  • a-z: 97-122

Extended : 128-255

所以普通的的话128个就够了,要是所有的话就是256了。

判断c是为否alphanumeric:

c >= 'a' && c <='z' || 小写
c >= 'A' && c <= 'Z' || 大写
c >= '0' && c <= '9' 数字

判断c是否相等: case insensitive

public boolean areEqual(char c1, char c2){
 if (c1 == c2) return true;
 if (c1 >= '0' && c1 <= '9' || c2 >= '0' && c2 <= '9') return false;
 if (Math.abs(c1 - c2) == Math.abs('A' - 'a')) return true;
 return false;
 }

如果用java内置method的话:

Character.isLetterOrDigit(c)
Character.toLowerCase(c)
s.replaceAll("[^A-Za-z0-9]", "").toLowerCase();
String rev = new StringBuffer(actual).reverse().toString();

ascii-codes-table1

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: