Difference between revisions of "Utf8.len"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
+
'''Available since:''' Gideros 2016.06<br/>
'''<translate>Available since</translate>:''' Gideros 2016.06<br/>
+
'''Class:''' [[utf8]]<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/utf8|utf8]]<br/>
+
 
=== <translate>Description</translate> ===
+
=== Description ===
<translate>Returns the number of UTF-8 characters in string s that start between positions i and j (both inclusive). The default for i is 1 and for j is -1. If it finds any invalid byte sequence, returns a false value plus the position of the first invalid byte.</translate>
+
Returns the number of UTF-8 characters in string ''s'' that start between positions ''i'' and ''j'' (both inclusive).
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
(number) = utf8.len(s,i,j)
 
(number) = utf8.len(s,i,j)
</source>
+
</syntaxhighlight>
=== <translate>Parameters</translate> ===
+
The default for i is 1 and for j is -1. If it finds any invalid byte sequence, returns a false value plus the position of the first invalid byte.
'''s''': (string) <translate></translate> <br/>
+
 
'''i''': (number) <translate></translate> '''optional'''<br/>
+
=== Parameters ===
'''j''': (number) <translate></translate> '''optional'''<br/>
+
'''s''': (string) string<br/>
=== <translate>Return values</translate> ===
+
'''i''': (number) start at position '''optional'''<br/>
'''<translate>Returns</translate>''' (number) <translate>number of characters</translate><br/>
+
'''j''': (number) end at position '''optional'''<br/>
 +
 
 +
=== Return values ===
 +
'''Returns''' (number) number of characters<br/>
 +
 
 +
=== Example ===
 +
<syntaxhighlight lang="lua">
 +
local str = "Hélène"
 +
local str_length = utf8.len(str)
 +
</syntaxhighlight>
  
 
{{Utf8}}
 
{{Utf8}}

Revision as of 21:29, 1 December 2023

Available since: Gideros 2016.06
Class: utf8

Description

Returns the number of UTF-8 characters in string s that start between positions i and j (both inclusive).

(number) = utf8.len(s,i,j)

The default for i is 1 and for j is -1. If it finds any invalid byte sequence, returns a false value plus the position of the first invalid byte.

Parameters

s: (string) string
i: (number) start at position optional
j: (number) end at position optional

Return values

Returns (number) number of characters

Example

local str = "Hélène"
local str_length = utf8.len(str)