non printable characters in java
Please, can you give me a list of non printable characters in java program开发者_JAVA百科ming? Thank you in advance.
Java uses the Unicode standard, so you should be asking about non-printable (non-printing?) characters in Unicode.
http://en.wikipedia.org/wiki/Unicode_control_characters
Java strings are unicode strings. Unicode doesn't have a concept of "non-printable" characters, exactly, but the ASCII non-printable range, along with several other characters, are considered Unicode control characters.
Are spaces printable? What about the private use area? Please modify the code to your definition of "printable" :)
import static java.lang.Character.*;
for (int i=0; i<MAX_CODE_POINT; i++) {
int t = getType(i);
boolean p = t == CONTROL || t == CONNECTOR_PUNCTUATION || t == CURRENCY_SYMBOL || t == DASH_PUNCTUATION || t == DECIMAL_DIGIT_NUMBER || t == ENCLOSING_MARK || t == END_PUNCTUATION || t == FINAL_QUOTE_PUNCTUATION || t == INITIAL_QUOTE_PUNCTUATION || t == LETTER_NUMBER || t == LOWERCASE_LETTER || t == MATH_SYMBOL || t == MODIFIER_LETTER || t == MODIFIER_SYMBOL || t == OTHER_LETTER || t == OTHER_NUMBER || t == OTHER_PUNCTUATION || t == OTHER_SYMBOL || t == START_PUNCTUATION || t == TITLECASE_LETTER || t == UPPERCASE_LETTER;
if (!p) {
System.out.println("Non printable codepoint " + i);
}
}
精彩评论