From ComputerCraftJump to navigation Jump to search
Colon notation: str:len()
Return the number of bytes in str.
The number of bytes in a string is not necessarily equivalent to its amount of characters! Many Unicode characters take up more than one byte. For example,
2. Hence, string.len only returns the amount of characters if str is encoded in an encoding that only uses one byte per character, such as ASCII.
Note: You can also use
|Read a line from the user, then print the length of the string they entered.|
|Output||Depends on what the user wrote. For instance, if they were to enter
Retrieved from "https://wiki.computercraft.cc/index.php?title=String.len&oldid=5415"