10

Just tried to convert byte to uint using Solidity 0.5.x:

uint length = uint(arr[i]);

and got:

MyCode.sol:88:29: TypeError: Explicit type conversion not allowed from "bytes1" to "uint256".
       uint length = uint(arr[i]);
                          ^----^
k06a
  • 3,016
  • 2
  • 21
  • 35

1 Answers1

16

The shortest solution I discovered after several tries:

uint length = uint(uint8(arr[i]));
k06a
  • 3,016
  • 2
  • 21
  • 35