ethereum / wiki

The Ethereum Wiki
https://www.ethereum.org
14.75k stars 2.56k forks source link

What is the meaining of ord(input) in RLP code example? #687

Open Bowfish opened 4 years ago

Bowfish commented 4 years ago

In the RLP encoding section there is this pseudo code. What does ord(input) < 0x80 in the third line mean? What would be the c or c++ equivalent for this?

def rlp_encode(input):
    if isinstance(input,str):
        if len(input) == 1 and ord(input) < 0x80: return input
        else: return encode_length(len(input), 0x80) + input
    elif isinstance(input,list):
        output = ''
        for item in input: output += rlp_encode(item)
        return encode_length(len(output), 0xc0) + output