Difference between revisions of "Utf8.width"
From GiderosMobile
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
'''Available since:''' Gideros 2016.06<br/> | '''Available since:''' Gideros 2016.06<br/> | ||
+ | '''Class:''' [[utf8]]<br/> | ||
+ | |||
=== Description === | === Description === | ||
− | + | Calculates the width of UTF-8 string ''s''. | |
− | < | + | <syntaxhighlight lang="lua"> |
(number) = utf8.width(s,ambi_is_double,default_width) | (number) = utf8.width(s,ambi_is_double,default_width) | ||
− | </ | + | </syntaxhighlight> |
+ | |||
+ | If ''ambi_is_double'' is given, the ambiguous width character width is 2, otherwise it is 1. | ||
+ | |||
+ | fullwidth/doublewidth character width is 2, and other characters width is 1. | ||
+ | |||
+ | If ''default_width'' is given, it will be the width of unprintable character, used to display a non-character mark for these characters. | ||
+ | |||
+ | If ''s'' is a code point, returns the width of this code point. | ||
+ | |||
=== Parameters === | === Parameters === | ||
− | '''s''': (string) | + | '''s''': (string) <br/> |
− | '''ambi_is_double''': (boolean) | + | '''ambi_is_double''': (boolean) '''optional'''<br/> |
− | '''default_width''': (number) | + | '''default_width''': (number) '''optional'''<br/> |
+ | |||
=== Return values === | === Return values === | ||
− | '''Returns''' (number) width<br/> | + | '''Returns''' (number) string width<br/> |
+ | |||
+ | {{Utf8}} |
Latest revision as of 22:24, 1 December 2023
Available since: Gideros 2016.06
Class: utf8
Description
Calculates the width of UTF-8 string s.
(number) = utf8.width(s,ambi_is_double,default_width)
If ambi_is_double is given, the ambiguous width character width is 2, otherwise it is 1.
fullwidth/doublewidth character width is 2, and other characters width is 1.
If default_width is given, it will be the width of unprintable character, used to display a non-character mark for these characters.
If s is a code point, returns the width of this code point.
Parameters
s: (string)
ambi_is_double: (boolean) optional
default_width: (number) optional
Return values
Returns (number) string width