NSException: NSStringCompareMBS

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

NSStringCompareMBS(s as string, t as string, options as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
global method Cocoa MBS Main Plugin 8.6 ✅ Yes ❌ No ❌ No ✅ Yes All
Compares two things using the Cocoa string functions.
Example
// constants for the function:
const NSCaseInsensitiveSearch = 1
const NSLiteralSearch = 2
const NSBackwardsSearch = 4
const NSAnchoredSearch = 8
const NSNumericSearch = 64
const NSDiacriticInsensitiveSearch = 128
const NSWidthInsensitiveSearch = 256
const NSForcedOrderingSearch = 512

const NSOrderedAscending = -1
const NSOrderedSame = 0
const NSOrderedDescending = 1

if NSStringCompareMBS("Hello","hello", NSCaseInsensitiveSearch)=0 then
msgbox "equal (correct)"
else
msgbox "not equal"
end if

if NSStringCompareMBS("Hello","hello", 0)=0 then
msgbox "equal"
else
msgbox "not equal (correct)"
end if

if NSStringCompareMBS("Hello","Hellö", NSDiacriticInsensitiveSearch)=0 then
msgbox "equal (correct)"
else
msgbox "not equal"
end if

Following constants can be used for the compare:

NSCaseInsensitiveSearch1Case Insensitive
NSLiteralSearch2Exact character-by-character equivalence
NSBackwardsSearch4Search from end of source string
NSAnchoredSearch8Search is limited to start (or end, if NSBackwardsSearch) of source string
NSNumericSearch64Added in 10.2; Numbers within strings are compared using numeric value, that is, Foo2.txt < Foo7.txt < Foo25.txt; only applies to compare methods, not find
NSDiacriticInsensitiveSearch128If specified, ignores diacritics (o-umlaut = o)
NSWidthInsensitiveSearch256If specified, ignores width differences ('a' = UFF41)
NSForcedOrderingSearch512If specified, comparisons are forced to return either NSOrderedAscending or NSOrderedDescending if the strings are equivalent but not strictly equal, for stability when sorting (e.g. "aaa" > "AAA" with NSCaseInsensitiveSearch specified)

The constants NSDiacriticInsensitiveSearch, NSWidthInsensitiveSearch and NSForcedOrderingSearch are only for Mac OS X 10.5 and newer versions.

Returns value constants:
NSOrderedAscending-1
NSOrderedSame0
NSOrderedDescending1

Some examples using this global method:

Blog Entries

The items on this page are in the following plugins: MBS Main Plugin.


💬 Ask a question or report a problem