메뉴 건너뛰기

이노쿼츠, 이노트리, ETL, Talend

InnoQuartz Technical Support

Tip HexToChar Function

jhpark 2016.08.24 01:34 조회 수 : 19813

HexToChar Function

public static String hexToChar(String hex) {
    if (hex == null)
        return "";

    if (hex.length() % 2 != 0) {
        return "";
    }

    ByteBuffer buff = ByteBuffer.allocate(hex.length() / 2);

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < hex.length() - 1; i += 2) {
        buff.put((byte) Integer.parseInt(hex.substring(i, i + 2), 16));
    }

    buff.rewind();

    Charset cs = Charset.forName("EUC-KR");
    CharBuffer cb = cs.decode(buff);

    sb.append(cb.toString());

    String str = sb.toString();

    return str;
}
위로