>>> hex_repr({"A":0x1,"B":0xabc})
    'A=$01 B=$0abc'
175613
def hex_repr(d):
    
    txt = []
    for k, v in sorted(d.items()):
        if isinstance(v, int):
            txt.append("%s=%s" % (k, nice_hex(v)))
        else:
            txt.append("%s=%s" % (k, v))
    return " ".join(txt)
117501
def _create_hexdump(src, start_offset=0, length=16):
        
        FILTER = "".join((len(repr(chr(x))) == 3) and chr(x) or "." for x in range(256))
        pattern = "{{0:04X}}   {{1:<{0}}}  {{2}}\n".format(length * 3)

        # Convert raw data to str (Python 3 compatibility)
        src = to_str(src, "latin-1")

        result = []
        for i in range(0, len(src), length):
            s = src[i : i + length]
            hexa = " ".join("{0:02X}".format(ord(x)) for x in s)
            printable = s.translate(FILTER)
            result.append(pattern.format(i + start_offset, hexa, printable))

        return "".join(result)
500751
def _replacer(x):
    
    # get the hex repr of the binary char and remove 0x and pad by pad_size
    # zeros
    try:
        hexin = ord(x)
    except TypeError:
        # bytes literals masquerade as ints when iterating in py3
        hexin = x

    return hex(hexin)
617090
function hexToBytes(hex) {
    var arr = new Uint8Array(Math.ceil(hex.length / 2));
    for (var i = 0; i < arr.length; i++) {
        arr[i] = parseInt(hex.substr(i * 2, 2), 16);
    }
    return arr;
}
40120
def char_repl(x):
    """"""
    r = ""
    for c in x:
        if ord(c) > 255:
            r += "?"
        else:
            r += c
    return r
329804
def unhex(inp):
    ''''''
    res = inp.split(r'\x')
    for i in xrange(1, len(res)):
        item = res[i]
        try:
            res[i] = _hextochr[item[:2]] + item[2:]
        except KeyError:
            res[i] = '%' + item
        except UnicodeDecodeError:
            res[i] = unichr(int(item[:2], 16)) + item[2:]
    return ''.join(res)
800627
def hexdump(bytestr, width=75, height=24, snipat=-2, modulo=2, ellipsis=None):
    
    size = len(bytestr)
    if size < 1 or width < 2 or height < 1:
        return ''
    if height == 1:
        addr = b''
        bytesperline = min(modulo * (((width - len(addr)) // 4) // modulo),
                           size)
        if bytesperline < 1:
            return ''
        nlines = 1
    else:
        addr = b'%%0%ix: ' % len(b'%x' % size)
        bytesperline = min(modulo * (((width - len(addr % 1)) // 4) // modulo),
                           size)
        if bytesperline < 1:
            return ''
        width = 3*bytesperline + len(addr % 1)
        nlines = (size - 1) // bytesperline + 1

    if snipat is None or snipat == 1:
        snipat = height
    elif 0 < abs(snipat) < 1:
        snipat = int(math.floor(height * snipat))
    if snipat < 0:
        snipat += height

    if height == 1 or nlines == 1:
        blocks = [(0, bytestr[:bytesperline])]
        addr = b''
        height = 1
        width = 3 * bytesperline
    elif height is None or nlines <= height:
        blocks = [(0, bytestr)]
    elif snipat <= 0:
        start = bytesperline * (nlines - height)
        blocks = [(start, bytestr[start:])]  # (start, None)
    elif snipat >= height or height < 3:
        end = bytesperline * height
        blocks = [(0, bytestr[:end])]  # (end, None)
    else:
        end1 = bytesperline * snipat
        end2 = bytesperline * (height - snipat - 1)
        blocks = [(0, bytestr[:end1]),
                  (size-end1-end2, None),
                  (size-end2, bytestr[size-end2:])]

    ellipsis = b'...' if ellipsis is None else str2bytes(ellipsis)
    result = []
    for start, bytestr in blocks:
        if bytestr is None:
            result.append(ellipsis)  # 'skip %i bytes' % start)
            continue
        hexstr = binascii.hexlify(bytestr)
        strstr = re.sub(br'[^\x20-\x7f]', b'.', bytestr)
        for i in range(0, len(bytestr), bytesperline):
            h = hexstr[2*i:2*i+bytesperline*2]
            r = (addr % (i + start)) if height > 1 else addr
            r += b' '.join(h[i:i+2] for i in range(0, 2*bytesperline, 2))
            r += b' ' * (width - len(r))
            r += strstr[i:i+bytesperline]
            result.append(r)
    result = b'\n'.join(result)
    if sys.version_info[0] == 3:
        result = result.decode('ascii')
    return result
214954
private static int scanUriEscape(ByteToChar converter,
                                   byte []rawUri, int i, int len)
    throws IOException
  {
    int ch1 = i < len ? (rawUri[i++] & 0xff) : -1;

    if (ch1 == 'u') {
      ch1 = i < len ? (rawUri[i++] & 0xff) : -1;
      int ch2 = i < len ? (rawUri[i++] & 0xff) : -1;
      int ch3 = i < len ? (rawUri[i++] & 0xff) : -1;
      int ch4 = i < len ? (rawUri[i++] & 0xff) : -1;

      converter.addChar((char) ((toHex(ch1) << 12) +
                                (toHex(ch2) << 8) + 
                                (toHex(ch3) << 4) + 
                                (toHex(ch4))));
    }
    else {
      int ch2 = i < len ? (rawUri[i++] & 0xff) : -1;

      int b = (toHex(ch1) << 4) + toHex(ch2);;

      converter.addByte(b);
    }

    return i;
  }
1010266
def calculate_hex(hex_string):
        """"""
        hex_conv = hex_string.split(':')
        converted_hex = (int(hex_conv[0], 16) + int(hex_conv[1], 16))/8192

        return converted_hex
1024762
def hexadecimal(token):
        
        token = ''.join([ c for c in token if c.isalnum() ])
        if len(token) % 2 != 0:
            raise ValueError("Missing characters in hex data")
        data = ''
        for i in compat.xrange(0, len(token), 2):
            x = token[i:i+2]
            d = int(x, 16)
            s = struct.pack('<B', d)
            data += s
        return data
1065159
def rgb_2_hex(self, r, g, b):
        
        return "#{:02X}{:02X}{:02X}".format(int(r * 255), int(g * 255), int(b * 255))
650872
def rgb_to_hex(rgba):
    
    rgba = rgba.split('/')
    hex_value = '#' + rgba[0][:2] + rgba[1][:2] + rgba[2][:2]
    return hex_value
762083
function rgb(hexStr) {
  const hex = hexStr.replace(/^#/, '');
  const fullHex = hex.length === 3
    ? `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`
    : hex;

  const num = parseInt(fullHex, 16);
  // eslint-disable-next-line no-bitwise, no-mixed-operators
  return [num >> 16, num >> 8 & 255, num & 255].join(', ');
}
379032
def hex2rgb(hexvalue):
    """"""

    # Make sure a possible '#' char is eliminated
    # before processing the color.
    if ('#' in hexvalue):
        hexcolor = hexvalue.replace('#', '')
    else:
        hexcolor = hexvalue

    # Hex colors have a fixed length of 6 characters excluding the '#'
    # TODO: Include custom exception here, even if it should never happen.
    if (len(hexcolor) != 6):
        print ("Unexpected length of hex color value.\nSix characters excluding \'#\' expected.")
        return 0

    # Convert each two characters of
    # the hex to an RGB color value.
    r = int(hexcolor[0:2], HEX_BASE)
    g = int(hexcolor[2:4], HEX_BASE)
    b = int(hexcolor[4:6], HEX_BASE)

    return r, g, b
96577
def bin_hex_type(arg):
	""""""
	if re.match(r'^[a-f0-9]{2}(:[a-f0-9]{2})+$', arg, re.I):
		arg = arg.replace(':', '')
	elif re.match(r'^(\\x[a-f0-9]{2})+$', arg, re.I):
		arg = arg.replace('\\x', '')
	try:
		arg = binascii.a2b_hex(arg)
	except (binascii.Error, TypeError):
		raise argparse.ArgumentTypeError("{0} is invalid hex data".format(repr(arg)))
	return arg
393366
def hex2rgb(h):
    
    if not h.startswith('#') or len(h) != 7:
        raise ValueError("Does not look like a hex color: '{0}'".format(h))
    return ','.join(map(str, (
        int(h[1:3], 16),
        int(h[3:5], 16),
        int(h[5:7], 16),
    )))
712563
static function bin2str( $hex_data )
    {
        $str='';
        $upto = strlen($hex_data);
        for ($i = 0; $i < $upto; $i+= 2) {
            $hexPair = $hex_data[$i].$hex_data [$i+1];
            /* if hex value starts with 0 (00, 0D, 0A...),
             * assume it's nondisplayable.
             * Replace with a space (hex 20)
             */
             if ($hex_data[$i] == '0') {
                 $hexPair = '20'; // space
             } //(if($hex_data[$i] == '0') ) 
             // break;
             $str.= chr(hexdec($hexPair));
             //$str.= chr(hexdec($hex_data[$i].$hex_data [$i+1]));
        }
        
        return $str;
     }