Utf8.width: Difference between revisions

From GiderosMobile
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
'''Available since:''' Gideros 2016.06<br/>
'''<translate>Available since</translate>:''' Gideros 2016.06<br/>
=== Description ===
=== <translate>Description</translate> ===
<translate>calculate the width of UTF-8 string s. if ambi_is_double is given, the ambiguous width character's width is 2, otherwise it's 1. fullwidth/doublewidth character's width is 2, and other character's width is 1. if default_width is given, it will be the width of unprintable character, used display a non-character mark for these characters. if s is a code point, return the width of this code point.</translate>
<translate>calculate the width of UTF-8 string s. if ambi_is_double is given, the ambiguous width character's width is 2, otherwise it's 1. fullwidth/doublewidth character's width is 2, and other character's width is 1. if default_width is given, it will be the width of unprintable character, used display a non-character mark for these characters. if s is a code point, return the width of this code point.</translate>
<source lang="lua">
<source lang="lua">
(number) = utf8.width(s,ambi_is_double,default_width)
(number) = utf8.width(s,ambi_is_double,default_width)
</source>
</source>
=== Parameters ===
=== <translate>Parameters</translate> ===
'''s''': (string) <translate></translate> <br/>
'''s''': (string) <translate></translate> <br/>
'''ambi_is_double''': (boolean) <translate></translate> '''optional'''<br/>
'''ambi_is_double''': (boolean) <translate></translate> '''optional'''<br/>
'''default_width''': (number) <translate></translate> '''optional'''<br/>
'''default_width''': (number) <translate></translate> '''optional'''<br/>
=== Return values ===
=== <translate>Return values</translate> ===
'''Returns''' (number) <translate>width</translate><br/>
'''<translate>Returns</translate>''' (number) <translate>width</translate><br/>

Revision as of 06:28, 24 August 2018

Available since: Gideros 2016.06

Description

calculate the width of UTF-8 string s. if ambi_is_double is given, the ambiguous width character's width is 2, otherwise it's 1. fullwidth/doublewidth character's width is 2, and other character's width is 1. if default_width is given, it will be the width of unprintable character, used display a non-character mark for these characters. if s is a code point, return the width of this code point.

(number) = utf8.width(s,ambi_is_double,default_width)

Parameters

s: (string)
ambi_is_double: (boolean) optional
default_width: (number) optional

Return values

Returns (number) width