如何用Java识别中文和国际音标

How to identify Chinese and IPA using java?

Java Code:

public class UnicodeTest {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  String sentence = "国际ɳʅ";
  for (int i = 0; i < sentence.length(); i++) {
   char c = sentence.charAt(i);
   if ((c >= 0x4e00) && (c <= 0x9fbb)) {
    System.out.println("This is Chinese");
   }
   if (java.lang.Character.UnicodeBlock.of(c).equals(java.lang.Character.UnicodeBlock.IPA_EXTENSIONS)) {
    System.out.println("This is IPA");
   }
  }

 }

}

Resource:

UnicodeBlock

Code Charts - Scripts

你可能感兴趣的:(java)