Utf8.len

From Multi Theft Auto: Wiki
Revision as of 04:12, 15 February 2016 by Necktrox (talk | contribs) (Created page with "__NOTOC__ {{Shared function}} Returns the length of the string passed. ==Syntax== <syntaxhighlight lang="lua">int utf8.len ( string input )</syntaxhighlight> ===Required Arguments=== *'''input:''' A s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Returns the length of the string passed.

Syntax

int utf8.len ( string input )

Required Arguments

  • input: A string character sequence

Returns

Returns the length of the string as a number.

Example

Click to collapse [-]
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 )
        end
    end
)

See Also