Converts input to the hex string
    :param x:
    :return:
187016
def to_hex(x):
    
    if isinstance(x, bytearray):
        x = bytes(x)
    elif isinstance(x, (list, tuple)):
        x = bytes(bytearray(x))
    if isinstance(x, basestring):
        return base64.b16encode(x).decode('ascii')
    else:
        raise ValueError('Unknown input argument type')
476857
function( input ) {

    var len = input.length
    var chr, out = ''

    function hex( number ) {
      return number.toString( 16 ).toUpperCase()
    }

    for( var i = 0; i < len; i++ ) {
      chr = input.charCodeAt( i )
      if( chr >= 0x41 && chr <= 0x5A ) {
        out = out + input[i]
      } else if( chr >= 0x61 && chr <= 0x7A ) {
        out = out + input[i]
      } else if( chr >= 0x30 && chr <= 0x39 ) {
        out = out + input[i]
      } else if( input[i].match( /[-_.!~*'()]/ ) ) {
        out = out + input[i]
      } else if( chr <= 0x007F ) {
        out = out + '%' + hex( chr )
      } else if( chr <= 0x07FF ) {
        out = out + '%' + hex( 0xC0 | (chr >>   6) )
        out = out + '%' + hex( 0x80 | (chr & 0x3F) )
      } else {
        out = out + '%' + hex( 0xE0 | (chr >> 12) )
        out = out + '%' + hex( 0x80 | ((chr >> 6) & 0x3F) )
        out = out + '%' + hex( 0x80 | (chr & 0x3F) )
      }
    }

    return out

  }
697191
def print_hex(self, value, justify_right=True):
        
        if value < 0 or value > 0xFFFF:
            # Ignore out of range values.
            return
        self.print_number_str('{0:X}'.format(value), justify_right)
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)
162608
def encode_hex(self, hex_str):
        
        numbers = (int('1' + hex_str[i:i+12], 16)
                   for i in range(0, len(hex_str), 12))
        try:
            return self.encode(*numbers)
        except ValueError:
            return ''
1285491
function(x) {
      var b = prng.getBytesSync(x.length);
      for(var i = 0; i < x.length; ++i) {
        x[i] = b.charCodeAt(i);
      }
    }
169080
def HexEscape(self, string, match, **_):
    """"""
    hex_string = match.group(1)
    try:
      self.string += binascii.unhexlify(hex_string).decode("utf-8")
    # TODO: In Python 2 `binascii` throws `TypeError` for invalid
    # input values (for whathever reason). This behaviour is fixed in Python 3
    # where `binascii.Error` (a subclass of `ValueError`) is raised. Once we do
    # not have to support Python 2 anymore, this `TypeError` catch should be
    # removed.
    except (binascii.Error, TypeError) as error:
      raise ParseError("Invalid hex escape '{}': {}".format(hex_string, error))
335508
def hex_to_xy(self, h):
        
        rgb = self.color.hex_to_rgb(h)
        return self.rgb_to_xy(rgb[0], rgb[1], rgb[2])
888196
def hex(self):
        
        return "#{:02x}{:02x}{:02x}".format(self._r, self._g, self._b).upper()
1315758
def stringify(self):
        
        hexcode = "#"
        for x in self.value:
            part = hex(x)[2:]
            if len(part) < 2: part = "0" + part
            hexcode += part
        return hexcode
863678
public String form( int x ) {
        String r;
        int s = 0;

        if (fmt == 'd' || fmt == 'i') {
            if (x < 0) {
                r = ("" + x).substring(1);
                s = -1;
            } else {
                r = "" + x;
                s = 1;
            }
        } else {
            long xl = x & 0x00000000FFFFFFFFL;
            if (fmt == 'u') {
                r = "" + xl;
                s = 1;
            } else if (fmt == 'o') {
                r = convert(xl, 3, "01234567");
            } else if (fmt == 'x') {
                r = convert(xl, 4, "0123456789abcdef");
            } else if (fmt == 'X') {
                r = convert(xl, 4, "0123456789ABCDEF");
            } else {
                throw new java.lang.IllegalArgumentException();
            }
        }

        return pad(sign(s, r));
    }
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)
83398
def rgb_to_hex(color):
    
    rgb = eval(color.replace('rgb', ''))
    # return '#'+''.join(map(chr, rgb)).encode('hex')
    return '#' + ''.join(['{0:02x}'.format(x).upper() for x in rgb])
919821
public static function str2hex(string $x): string
    {
        $string = '';

        foreach (str_split($x) as $char) {
            $string .= sprintf('%02X', ord($char));
        }

        return $string;
    }
801373
def _xr_to_keyset(line):
    '''
    
    '''
    tkns = [elm for elm in line.strip().split(":", 1) if elm]
    if len(tkns) == 1:
        return "'{0}': ".format(tkns[0])
    else:
        key, val = tkns
        return "'{0}': '{1}',".format(key.strip(), val.strip())
1070939
def random_hex(length):
    """"""
    return escape.to_unicode(binascii.hexlify(os.urandom(length))[length:])
734436
def hex(self):
        """"""
        props = self._message_properties()
        msg = bytearray([MESSAGE_START_CODE_0X02, self._code])

        for prop in props:
            # pylint: disable=unused-variable
            for key, val in prop.items():
                if val is None:
                    pass
                elif isinstance(val, int):
                    msg.append(val)
                elif isinstance(val, Address):
                    if val.addr is None:
                        pass
                    else:
                        msg.extend(val.bytes)
                elif isinstance(val, MessageFlags):
                    msg.extend(val.bytes)
                elif isinstance(val, bytearray):
                    msg.extend(val)
                elif isinstance(val, bytes):
                    msg.extend(val)
                elif isinstance(val, Userdata):
                    msg.extend(val.bytes)

        return binascii.hexlify(msg).decode()