Utf8.ncasecmp: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ {{Shared function}} Compares two strings in lower-case and returns the difference as a number value. ==Syntax== <syntaxhighlight lang="lua">int utf8.ncasecmp ( string a, string b )...") |
mNo edit summary |
||
Line 2: | Line 2: | ||
{{Shared function}} | {{Shared function}} | ||
Compares two strings in lower-case and returns the difference as a number value. | Compares two strings in lower-case and returns the difference indicator (see table below) as a number value. | ||
==Syntax== | ==Syntax== |
Revision as of 18:19, 15 February 2016
Compares two strings in lower-case and returns the difference indicator (see table below) as a number value.
Syntax
int utf8.ncasecmp ( string a, string b )
Required Arguments
- a: A string character sequence
- b: A string character sequence
Returns
Returns a number, which indicates the difference, see the table below for further information.
Indicators
Value | Meaning |
---|---|
-1 |
a < b |
0 |
a == b |
1 |
a > b |
Example
Click to collapse [-]
ServerThis example shows a simple comparsion of two different strings.
local a = "Hello" local b = "World" local result = utf8.ncasecmp( a, b ) if result == -1 then print( "a < b" ) -- printed elseif result == 0 then print( "a == b" ) elseif result == 1 then print( "a > b" ) end
Click to collapse [-]
ServerThis example shows how to greet a player, when he write 'hello' into the chat.
addEventHandler("onPlayerChat", root, function (message, messageType) if messageType == 0 and utf8.ncasecmp( message, "hello" ) == 0 then outputChatBox( "* Server: Hello!", source, 255, 100, 100 ) end end )
See Also
- utf8.byte
- utf8.char
- utf8.charpos
- utf8.escape
- utf8.find
- utf8.fold
- utf8.gmatch
- utf8.gsub
- utf8.insert
- utf8.len
- utf8.lower
- utf8.match
- utf8.ncasecmp
- utf8.next
- utf8.remove
- utf8.reverse
- utf8.sub
- utf8.title
- utf8.upper
- utf8.width
- utf8.widthindex