Utf8.sub

From Multi Theft Auto: Wiki
Revision as of 17:05, 15 February 2016 by Necktrox (talk | contribs) (Created page with "__NOTOC__ {{Shared function}} Returns a substring of the string passed. The substring starts at ''i''. If the third argument ''j'' is not given, the substring will end at the...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Returns a substring of the string passed. The substring starts at i. If the third argument j is not given, the substring will end at the end of the string. If the third argument is given, the substring ends at and includes j.

Syntax

string utf8.sub ( 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: A number representing the beginning position (may be negative).
  • j: A number representing the ending position (may be negative).

Returns

Returns a string substring of the original string, containing the selected range.

Example

Click to collapse [-]
Client

This example shows how to extract a substring from a UTF-8 string.

local input = "Yarın Salı"

local output = utf8.sub( input, 1, 4 )
outputConsole( output ) -- Yarı

local output = utf8.sub( input, -4 )
outputConsole( output ) -- Salı

local output = utf8.sub( input, -4, -1 )
outputConsole( output ) -- Salı

See Also