Difference between revisions of "Utf8.width"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== <translate>Description</translate> ===
 
=== <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">
+
<syntaxhighlight lang="lua">
 
(number) = utf8.width(s,ambi_is_double,default_width)
 
(number) = utf8.width(s,ambi_is_double,default_width)
 
</source>
 
</source>

Revision as of 14:32, 13 July 2023


Available since: Gideros 2016.06
Class: utf8

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. <syntaxhighlight lang="lua"> (number) = utf8.width(s,ambi_is_double,default_width) </source>

Parameters

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

Return values

Returns (number) width