utf8.len
Client-side
Server-side
Shared
Returns the length of the string passed.
Syntax
int utf8.len ( string input, [ int i = 1, int j = utf8.len( input ) ] )Required Arguments
- input: A string character sequence.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- i (default: 1): An integer representing the beginning position for measuring the length of the section (may be negative).
- j (default: utf8.len( input )): An integer representing the ending position for measuring the length of the section (may be negative).
Returns
- int: length
Returns the length of the string as an integer.
Code Examples
client
This example calculates the length of the input of the command /length and shows it in the chatbox.
addCommandHandler("length", function(command, ...) local input = table.concat({...}, " ")
if input then local length = utf8.len(input) outputChatBox("* Length of your input: " .. length) endend)