2014년 3월 11일 화요일

JAVA - 유니코드 한글변환

                     class UnicodeToChar {
                         public void unicodeToChar() {
                             String[] rawUnicode ="\uc548\ub155\ud558\uc138\uc694".split("");
                            
                             int intVal = 0;
                             char[] chVal;
                            
                             System.out.print("(HEX)" + "\t" + "(INT)" + "\t" +"(Decoded)");
//                           StringBuffer sb = new StringBuffer(6);
                             for (int i = 0; i < rawUnicode.length; i++){
                                 chVal = rawUnicode[i].toCharArray();
                                 for(int j = 0; j < chVal.length; j++){
                                     intVal = chVal[j];
//                                   sb.append("\\u").append(Integer.toHexString(intVal));
//                                   System.out.println("### sb.toString()" + sb.toString());
                                     System.out.print(Integer.toHexString(intVal) + "\t" + intVal + "\t" + chVal[j]);
                                 }
                                 System.out.println();
                             }
                         }
                     }
                     /*
                     (HEX)    (INT)    (Decoded)
                     c548    50504   
                     b155    45397   
                     d558    54616   
                     c138    49464   
                     c694    50836   

                     */

댓글 없음:

댓글 쓰기