Indicates if the given character is textual (ISO Latin 1 and not a control character). - Java java.lang

Java examples for java.lang:char

Description

Indicates if the given character is textual (ISO Latin 1 and not a control character).

Demo Code


//package com.java2s;

public class Main {
    /**//from  w ww.  jav a2s.c o m
     * Indicates if the given character is textual (ISO Latin 1 and not a control character).
     * 
     * @param character
     *            The character to test.
     * @return True if the given character is textual.
     */
    public static boolean isText(int character) {
        return isLatin1Char(character) && !isControlChar(character);
    }

    /**
     * Indicates if the given character is in ISO Latin 1 (8859-1) range. Note that this range is a superset of ASCII and a subrange of Unicode (UTF-8).
     * 
     * @param character
     *            The character to test.
     * @return True if the given character is in ISO Latin 1 range.
     */
    public static boolean isLatin1Char(int character) {
        return (character >= 0) && (character <= 255);
    }

    /**
     * Indicates if the given character is a control character.
     * 
     * @param character
     *            The character to test.
     * @return True if the given character is a control character.
     */
    public static boolean isControlChar(int character) {
        return ((character >= 0) && (character <= 31))
                || (character == 127);
    }
}

Related Tutorials