Utf8.len: Difference between revisions
Jump to navigation
Jump to search
m (tweaks) |
(Optional Arguments) |
||
Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">int utf8.len ( string input )</syntaxhighlight> | <syntaxhighlight lang="lua">int utf8.len ( string input [, int i = 1, int j = utf8.len( input ) ] )</syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''input:''' A string character sequence | *'''input:''' A string character sequence | ||
===Optional Arguments=== | |||
{{OptionalArg}} | |||
*'''i:''' An integer representing the beginning position for measuring the length of the section (may be negative). | |||
*'''j:''' An integer representing the ending position for measuring the length of the section (may be negative). | |||
===Returns=== | ===Returns=== |
Latest revision as of 08:27, 21 May 2016
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. For more information on optional arguments, see optional arguments.
- i: An integer representing the beginning position for measuring the length of the section (may be negative).
- j: An integer representing the ending position for measuring the length of the section (may be negative).
Returns
Returns the length of the string as an integer.
Example
Click to collapse [-]
ClientThis 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 ) end end )
See Also
Shared
- utf8.byte
- utf8.char
- utf8.charpos
- utf8.escape
- utf8.find
- utf8.fold
- utf8.gmatch
- utf8.gsub
- utf8.insert
- utf8.len
- utf8.lower
- utf8.match
- utf8.ncasecmp
- utf8.next
- utf8.remove
- utf8.reverse
- utf8.sub
- utf8.title
- utf8.upper
- utf8.width
- utf8.widthindex