본문 바로가기
개발자의 정보/Java & framework

Check Encoding on java

by pastory 2020. 2. 1.
String originalStr = "테스트"; // 테스트
String [] charSet = {"utf-8","euc-kr","ksc5601","iso-8859-1","x-windows-949"};

for (int i=0; i<charSet.length; i++) {
  
   for (int j=0; j<charSet.length; j++) {
      
      try {
         LOGGER.info("[" + charSet[i] +"," + charSet[j] +"] = " + new String(originalStr.getBytes(charSet[i]), charSet[j]));
      }
      catch (UnsupportedEncodingException e) {
         LOGGER.error(e.getLocalizedMessage(), e);
      }
   }
}

 

댓글