convert a raw string including non printable characters to hexadecimal encoded string.<br/>
@param {String} s raw string
@return {String} hexadecimal encoded string
@since 1.1.2
@example
rstrtohex("a\x00a") &rarr; "610061"
976030
function rstrtohex(s) {
    var result = "";
    for (var i = 0; i < s.length; i++) {
        result += ("0" + s.charCodeAt(i).toString(16)).slice(-2);
    }
    return result;
}
1140530
public static String unicodeEncode(String s) {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < s.length(); ++i) {
            char ch = s.charAt(i);
            if (ch >= '\u0080') {
                String st = Integer.toHexString(0x10000 + (int) ch);
                while (st.length() < 4) st = "0" + st;
                buf.append("\\u").append(st.subSequence(1, 5));
            } else {
                buf.append(ch);
            }
        }
        return buf.toString();
    }
10982
public static String md5Hex(String s) {
    try {
      MessageDigest messageDigest = MessageDigest.getInstance("MD5");
      byte[] md5bytes = messageDigest.digest(s.getBytes("UTF-8"));
      return ByteString.of(md5bytes).hex();
    } catch (NoSuchAlgorithmException e) {
      throw new AssertionError(e);
    } catch (UnsupportedEncodingException e) {
      throw new AssertionError(e);
    }
  }
155328
function convertData2Hexd (data) {
  if (!isHexString(data)) {
    var hex = ''
    for (var i = 0; i < data.length; i++) {
      hex += data.charCodeAt(i).toString(16)
    }
    return '0x' + hex
  }
  return data
}
425523
function(dec, bytes) {
    var hex = "",
        i;
    for (i = 0; i < bytes; i++) {
        hex += String.fromCharCode(dec & 0xff);
        dec = dec >>> 8;
    }
    return hex;
}
582859
function b64nltohex(s) {
    var b64 = s.replace(/[^0-9A-Za-z\/+=]*/g, '');
    var hex = b64tohex(b64);
    return hex;
}
906850
function b64tohex(s) {
        var ret = ""
        var i;
        var k = 0; // b64 state, 0-3
        var slop;
        for (i = 0; i < s.length; ++i) {
            if (s.charAt(i) == b64pad) break;
            v = b64map.indexOf(s.charAt(i));
            if (v < 0) continue;
            if (k == 0) {
                ret += int2char(v >> 2);
                slop = v & 3;
                k = 1;
            }
            else if (k == 1) {
                ret += int2char((slop << 2) | (v >> 4));
                slop = v & 0xf;
                k = 2;
            }
            else if (k == 2) {
                ret += int2char(slop);
                ret += int2char(v >> 2);
                slop = v & 3;
                k = 3;
            }
            else {
                ret += int2char((slop << 2) | (v >> 4));
                ret += int2char(v & 0xf);
                k = 0;
            }
        }
        if (k == 1)
            ret += int2char(slop << 2);
        return ret;
    }
1209743
function formatHex(t) { //char
		// not compatible with GWT...
		// return String.format("\\u%04x", (int)t);
		var sb = '';
		sb += '\\u';
		var s = t.charCodeAt(0).toString(16);
		for (var i = s.length; i < 4; i++) sb += '0';
		sb += s;
		return sb;
	}
806206
function stringToHex(value) {
  const val = value == null ? '' : value;

  let hex = '';
  let tmp = '';

  for (let i = 0; i < val.length; i++) {
    // Convert to Hex and Ensure it's in 2 digit sets
    tmp = ('0000' + val.charCodeAt(i).toString(16)).slice(-2);
    hex += '' + tmp;
  }

  return hex;
}
303408
public static byte[] hexStringToByteArray(String s) throws IOException {

        int     l    = s.length();
        byte[]  data = new byte[l / 2 + (l % 2)];
        int     n,
                b    = 0;
        boolean high = true;
        int     i    = 0;

        for (int j = 0; j < l; j++) {
            char c = s.charAt(j);

            if (c == ' ') {
                continue;
            }

            n = getNibble(c);

            if (n == -1) {
                throw new IOException(
                    "hexadecimal string contains non hex character");    //NOI18N
            }

            if (high) {
                b    = (n & 0xf) << 4;
                high = false;
            } else {
                b         += (n & 0xf);
                high      = true;
                data[i++] = (byte) b;
            }
        }

        if (!high) {
            throw new IOException(
                "hexadecimal string with odd number of characters");    //NOI18N
        }

        if (i < data.length) {
            data = (byte[]) ArrayUtil.resizeArray(data, i);
        }

        return data;
    }
770422
public static String convertText(String s) {
        StringCharacterIterator stringcharacteriterator = new StringCharacterIterator(s);
        StringBuffer stringbuffer = new StringBuffer();
        int ai[] = new int[s.length()];
        int i = 0;
        int j = 0;
        for(char c = stringcharacteriterator.first(); c != '\uFFFF'; c = stringcharacteriterator.next())
            if(c == '%')
            {
                c = stringcharacteriterator.next();
                if(c != '%')
                {
                    stringbuffer.append('%');
                    c = stringcharacteriterator.previous();
                } else
                {
                    c = stringcharacteriterator.next();
                    switch(c)
                    {
                    case 37: // '%'
                        stringbuffer.append('%');
                        break;

                    case 80: // 'P'
                    case 112: // 'p'
                        stringbuffer.append('\361');
                        break;

                    case 67: // 'C'
                    case 99: // 'c'
                        stringbuffer.append('\355');
                        break;

                    case 68: // 'D'
                    case 100: // 'd'
                        stringbuffer.append('\u00b0');
                        break;

                    case 85: // 'U'
                    case 117: // 'u'
                        ai[stringbuffer.length()] ^= 1;
                        i++;
                        break;

                    case 79: // 'O'
                    case 111: // 'o'
                        ai[stringbuffer.length()] ^= 2;
                        j++;
                        break;

                    default:
                        if(c >= '0' && c <= '9')
                        {
                            int k = 3;
                            char c1 = (char)(c - 48);
                            for(c = stringcharacteriterator.next(); c >= '0' && c <= '9' && --k > 0; c = stringcharacteriterator.next())
                                c1 = (char)(10 * c1 + (c - 48));

                            stringbuffer.append(c1);
                        }
                        c = stringcharacteriterator.previous();
                        break;
                    }
                }
            } else
            if(c == '^')
            {
                c = stringcharacteriterator.next();
                if(c == ' ')
                    stringbuffer.append('^');
            } else
            {
                stringbuffer.append(c);
            }
        s = Unicode.char2DOS437(stringbuffer, 2, '?');

		String ss = s;
		return ss;
	}
}
636359
function fullHex(hex) {
  return hex.length == 4 ?
    [ '#',
      hex.substring(1, 2), hex.substring(1, 2)
    , hex.substring(2, 3), hex.substring(2, 3)
    , hex.substring(3, 4), hex.substring(3, 4)
    ].join('') : hex
}
92041
function hex(s) {
    var m = /rgba?\((\d+), (\d+), (\d+)/.exec(s),
      c = s.split("");
    if (m) {
      s = ( m[1] << 16 | m[2] << 8 | m[3] ).toString(16);
      while (s.length < 6)
        s = "0" + s;
    }
    return "#" + (s.length == 6 ? s : c[1] + c[1] + c[2] + c[2] + c[3] + c[3]);
  }
68407
function b64toBA(s) {
  //piggyback on b64tohex for now, optimize later
  var h = b64tohex(s);
  var i;
  var a = new Array();
  for(i = 0; 2*i < h.length; ++i) {
    a[i] = parseInt(h.substring(2*i,2*i+2),16);
  }
  return a;
}
1188603
public static <S extends CharSequence> String hex(S s, int width, S separator) {
        return hex(s, width, separator, true, new StringBuilder()).toString();
    }
1374338
public static String convert32(String s)
    {
        try {
            byte[] bytes = s.getBytes();
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(bytes);
            bytes = md.digest();
            int j = bytes.length;
            char[] chars = new char[j * 2];
            int k = 0;
            for (int i = 0; i < bytes.length; i++) {
                byte b = bytes[i];
                chars[k++] = hexChars[b >>> 4 & 0xf];
                chars[k++] = hexChars[b & 0xf];
            }
            return new String(chars);
        }
        catch (Exception e){
            return null;
        }
    }
880647
def _convert_signed_hex(s):
    
    if s.startswith('0x') or s.startswith('-0x'):
        s = '{0:x}'.format(struct.unpack('Q', struct.pack('q', int(s, 16)))[0])
    return s.zfill(16)