Difference between revisions of "Utf8.sub"
From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2016.06<br/> === Description === Returns the substring of s that starts at i and continues until j; i and j can be negative. If j is a...") |
|||
Line 5: | Line 5: | ||
If, after the translation of negative indices, i is less than 1, it is corrected to 1. If j is greater than the string length, it is corrected to that length. If, after these corrections, i is greater than j, the function returns the empty string. | If, after the translation of negative indices, i is less than 1, it is corrected to 1. If j is greater than the string length, it is corrected to that length. If, after these corrections, i is greater than j, the function returns the empty string. | ||
<source lang="lua"> | <source lang="lua"> | ||
− | (string) | + | (string) = utf8.sub(s,i,j) |
</source> | </source> | ||
− | '''s | + | '''s''': (string) ''''''<br/> |
− | '''i | + | '''i''': (number) ''''''<br/> |
− | '''j | + | '''j''': (number) '''optional'''<br/> |
'''Returns''' (string) substring of s that starts at i and continues until j<br/> | '''Returns''' (string) substring of s that starts at i and continues until j<br/> |
Revision as of 10:20, 23 August 2018
Available since: Gideros 2016.06
Description
Returns the substring of s that starts at i and continues until j; i and j can be negative. If j is absent, then it is assumed to be equal to -1 (which is the same as the string length). In particular, the call string.sub(s,1,j) returns a prefix of s with length j, and string.sub(s, -i) returns a suffix of s with length i. If, after the translation of negative indices, i is less than 1, it is corrected to 1. If j is greater than the string length, it is corrected to that length. If, after these corrections, i is greater than j, the function returns the empty string.
(string) = utf8.sub(s,i,j)
's: (string) '
'i: (number) '
j: (number) optional
Returns (string) substring of s that starts at i and continues until j