utf8.ncasecmp()

Type Function
Library utf8.*
Return value Number
Revision Release 2022.3683
Keywords utf8, UTF-8, Unicode, string, ncasecmp

Overview

Compares strings a and b, ignoring case. Returns an integer as follows:

Condition Returns
a < b -1
a == b 0
a > b 1

Syntax

utf8.ncasecmp( a, b )
a (required)

String. The first string.

b (required)

String. The second string.

Example

local utf8 = require( "plugin.utf8" )

local str1 = "♡ 你好,世界 ♡"
local str2 = str1

print( utf8.ncasecmp( str1, str2 ) )  --> 0 (same string)

str2 = utf8.insert( str1, 3, "UTF-8 " )

print( utf8.ncasecmp( str1, str2 ) )  --> 1 (different strings)