mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
32 lines
680 B
Solidity
32 lines
680 B
Solidity
function length(bytes memory value) pure suffix returns (uint) {
|
|
return value.length;
|
|
}
|
|
|
|
contract C {
|
|
function empty() public pure returns (uint) {
|
|
return "" length;
|
|
}
|
|
|
|
function short() public pure returns (uint) {
|
|
return 'abcd' length;
|
|
}
|
|
|
|
function long() public pure returns (uint) {
|
|
return 'abcdefghijklmnop abcdefghijklmnop' length;
|
|
}
|
|
|
|
function hex_() public pure returns (uint) {
|
|
return hex'0123456789abcdef' length;
|
|
}
|
|
|
|
function unicode_() public pure returns (uint) {
|
|
return unicode"😃" length;
|
|
}
|
|
}
|
|
// ----
|
|
// empty() -> 0
|
|
// short() -> 4
|
|
// long() -> 33
|
|
// hex_() -> 8
|
|
// unicode_() -> 4
|