public static boolean isASCII(String str){
boolean ret = true;
char tch;
int tint;
for(int i = 0; i < str.length(); i++){
tch = str.charAt(i);
tint = (int)tch;
if(tint > 255){
ret = false;
break;
}
}
return ret;
}
这样对吗?
boolean ret = true;
char tch;
int tint;
for(int i = 0; i < str.length(); i++){
tch = str.charAt(i);
tint = (int)tch;
if(tint > 255){
ret = false;
break;
}
}
return ret;
}
这样对吗?
public static boolean isASCII(String str){
char tch;
int tint;
for(int i = 0; i < str.length(); i++){
tch = str.charAt(i);
tint = (int)tch;
if(tint > 255){
return false;
}
}
return true;
}
if (str == null || str==''){
return false;
} else {
var strlen = str.length;
var i = 0;
for (i=0;i < strlen;i++) {
if (str.substring(i,i+1) >= 'a' && str.substring(i,i+1) <= 'z') continue;
if (str.substring(i,i+1) >= 'A' && str.substring(i,i+1) <= 'Z') continue;
if (str.substring(i,i+1) >= '0' && str.substring(i,i+1) <= '9') continue;
if (str.substring(i,i+1) == '_' ) continue;
return false;
}
}
return true;
}