Java examples for java.lang:String Unicode
Indicates whether a character is classified as "Alphabetic" by the Unicode standard.
/*/*from ww w.jav a 2 s . co m*/ * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //package com.java2s; public class Main { /** * Indicates whether a character is classified as "Alphabetic" by the * Unicode standard. * * @param c * the character * @return true if the character is "Alphabetic" */ public static boolean isAlphabetic(final int c) { // http://www.unicode.org/Public/UNIDATA/UCD.html#Alphabetic // Generated from: Other_Alphabetic + Lu + Ll + Lt + Lm + Lo + Nl final int generalCategory = Character.getType((char) c); switch (generalCategory) { case Character.UPPERCASE_LETTER: // Lu case Character.LOWERCASE_LETTER: // Ll case Character.TITLECASE_LETTER: // Lt case Character.MODIFIER_LETTER: // Lm case Character.OTHER_LETTER: // Lo case Character.LETTER_NUMBER: // Nl return true; default: // TODO if (ch in Other_Alphabetic) return true; (Probably need // ICU4J for that) // Other_Alphabetic contains mostly more exotic characters return false; } } }