Timeline for Is it possible to check string variable's length inside the contract?
Current License: CC BY-SA 4.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
S Jan 6, 2022 at 21:06 | history | suggested | questionto42 | CC BY-SA 4.0 |
clear warning that this does not show the string length as you would normally understand it. Because I fell into it, not reading the edit since you just quickly copy and paste such a clear code statement.
|
Jan 6, 2022 at 16:01 | review | Suggested edits | |||
S Jan 6, 2022 at 21:06 | |||||
Oct 4, 2018 at 2:06 | history | edited | Tjaden Hess | CC BY-SA 4.0 |
added 201 characters in body
|
Oct 3, 2018 at 15:14 | comment | added | Tjaden Hess | I would argue that byte-length is the more important metric in most cases, since length in encodings like utf-8 is still upper-bounded by byte length. It seems rather arbitrary to assume that OP is using utf8 or any other particular encoding. | |
Oct 2, 2018 at 20:19 | comment | added | Symeof | This answer should be edited to include Alexey's comment. bytes(str).length does NOT give the intended behavior in some cases, so it must be used with caution. | |
Apr 5, 2017 at 15:09 | vote | accept | alper | ||
Apr 4, 2017 at 1:39 | comment | added | Alexey Barsuk | This way you can check th byte-length of string. If string encoding, for example UTF8, number of characters can differ from bytes(str).length | |
Apr 3, 2017 at 20:24 | review | Low quality posts | |||
Apr 3, 2017 at 23:19 | |||||
Apr 3, 2017 at 20:23 | history | edited | Tjaden Hess | CC BY-SA 3.0 |
added 7 characters in body
|
Apr 3, 2017 at 14:30 | review | Low quality posts | |||
Apr 3, 2017 at 15:25 | |||||
Apr 3, 2017 at 14:11 | history | answered | Tjaden Hess | CC BY-SA 3.0 |