01.JAVA/Java2008. 7. 11. 17:15
반응형


/**
  *
  * @param input
  *            체크할 값
  *
  * 한글 , 영어 , 특수 기호 값을 체크
  */
 public static void testChar(String input){
  boolean test = false;
  char[] charArray=input.toCharArray();


  for (int j=0; j<charArray.length; j++) {
   System.out.println(" 0x"+Integer.toHexString((int)charArray[j]));

   if (charArray[j] >= 'A' && charArray[j] <= 'Z' || charArray[j] >= 'a' && charArray[j] <= 'z'){
    System.out.println(charArray[j]+"=>"+"(English)");

   }else if (charArray[j]>='\uAC00' && charArray[j]<='\uD7A3'){
    System.out.print(charArray[j]+" =>"+"(한글)");

   }else if (
     (charArray[j]>='!' && charArray[j]<='/')  ||
     (charArray[j]>='[' && charArray[j]<=0x60)  ||
    
     (charArray[j]>='{' && charArray[j]<='~') ||
     (charArray[j]>=':' && charArray[j]<='@')
   ){
    System.out.println(charArray[j]+" =>"+"(특수 문자)");

   }else if (charArray[j]>='0' && charArray[j]<='9'){
    System.out.println(charArray[j]+"=>"+"(숫자)");

   }else {
    test = false;
    for (int jnx=0; jnx<ChoSung.length; jnx++){
     if(charArray[j]== ChoSung[jnx]){
      System.out.println(ChoSung[jnx]+ "초성");
      test = true;
      break;
     }
    }
    for (int jnx=0; test == false && jnx<JwungSung.length; jnx++){
     if(charArray[j]== JwungSung[jnx]){
      System.out.println(JwungSung[jnx] + " 중성 ");
      test = true;
      break;
     }
    }
    for (int jnx=0; test == false && jnx<JongSung.length; jnx++){
     if(charArray[j]== JongSung[jnx]){
      System.out.println(JongSung[jnx] + "종성");
      test = true;
      break;
     }
    }
   }
   System.out.println("");

  }

 }

Posted by 1010