Here you can find the source of toUtf8(String hex)
Parameter | Description |
---|---|
hex | a parameter |
public static String toUtf8(String hex)
//package com.java2s; //License from project: Open Source License public class Main { private static final String HEX_PREFIX = "0x"; /**//from w w w .j a v a 2 s . c o m * Method converts hex string into utf8 string * * @param hex * @return String */ public static String toUtf8(String hex) { String result = ""; int i = 0, length = hex.length(); if (hex.substring(0, 2).equals(HEX_PREFIX)) { i = 2; } for (; i < length; i += 2) { int code = Integer.parseInt(hex.substring(i, i + 2), 16); result += Character.toString((char) code); } return result; } }