<< Derby Performance | 首页 | 我收藏的链接(31) >>

如何用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

标签 :



发表评论 发送引用通报