UtfLen: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Server client function}} The function gets the real length of a string, in characters. ==Syntax== <syntaxhighlight lang="lua"> int utfLen ( string theString ) </syntaxhighlight> ===Required Arguments...")
 
mNo edit summary
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
{{Server client function}}
{{Server client function}}
The function gets the real length of a string, in characters.
The function gets the real length of a string, in characters.
Line 4: Line 5:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int utfLen ( string theString )
int utfLen ( string theString )
</syntaxhighlight>
</syntaxhighlight>


Line 13: Line 14:
Returns an ''[[int]]'' if the function was successful, ''false'' otherwise.
Returns an ''[[int]]'' if the function was successful, ''false'' otherwise.


==Example==
<section name="Client" class="client" show="true">
This example adds a command ''russian_text_length'' which prints out a length russian text.
<syntaxhighlight lang="lua">
addCommandHandler( 'russian_text_length',
function( )
outputChatBox( string.format( 'Russian text length is: %d', utfLen( 'Текст' ) ) )
end
)
</syntaxhighlight>
</section>
==See Also==
==See Also==
{{Utility_functions}}
{{Utility_functions}}

Latest revision as of 12:02, 27 February 2013

The function gets the real length of a string, in characters.

Syntax

int utfLen ( string theString )

Required Arguments

  • theString: The string to get the length of.

Returns

Returns an int if the function was successful, false otherwise.

Example

Click to collapse [-]
Client

This example adds a command russian_text_length which prints out a length russian text.

addCommandHandler( 'russian_text_length',
	function( )
		outputChatBox( string.format( 'Russian text length is: %d', utfLen( 'Текст' ) ) )
	end
)

See Also