Utf8.fold: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (note box about case folding)
m (tweaks)
Line 2: Line 2:
{{Shared function}}
{{Shared function}}
{{Note box|You may want to read up on [https://www.w3.org/International/wiki/Case_folding case folding] for more information about the use of this function.}}
{{Note box|You may want to read up on [https://www.w3.org/International/wiki/Case_folding case folding] for more information about the use of this function.}}
Converts a UTF-8 string to folded case (lowercase), which can be used to compare two strings. If ''input'' is an integer, it's treat as a code point and a convert code point (number) is returned.
Converts a UTF-8 string to folded case (lowercase), which can be used to compare two strings. If ''input'' is an integer, it's treat as a code point and a convert code point (integer) is returned.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">string utf8.lower ( string|int input )
<syntaxhighlight lang="lua">string|int utf8.lower ( string|int input )
string utf8.fold ( string|int input )</syntaxhighlight>
string|int utf8.fold ( string|int input )</syntaxhighlight>


===Required Arguments===
===Required Arguments===
Line 12: Line 12:


===Returns===
===Returns===
Returns a ''string'' in lowercase.
Returns a ''string'' in lowercase OR returns an ''integer'' (see description).


==Example==
==Example==

Revision as of 18:37, 15 February 2016

This template is no longer in use as it results in poor readability. Converts a UTF-8 string to folded case (lowercase), which can be used to compare two strings. If input is an integer, it's treat as a code point and a convert code point (integer) is returned.

Syntax

string|int utf8.lower ( string|int input )
string|int utf8.fold ( string|int input )

Required Arguments

  • input: A string character sequence OR an integer value

Returns

Returns a string in lowercase OR returns an integer (see description).

Example

Click to collapse [-]
Server

This example shows how to convert a string to lowercase, which can be used to compare with other folded strings.

local output = utf8.lower( "WHAT ARE YOU UP TO? Do you like uppercase?" )
print( output ) -- what are you up to? do you like uppercase?

local value = utf8.fold( 1088 )
print( type( value ) ) -- number

See Also