One Logo Pool Ball
Foundation · IOS API REFERENCE

CharacterSet

struct · iOS 8.0+ · SDK 27.1

struct CharacterSet

A set of Unicode character values for use in search operations. A `CharacterSet` represents a set of Unicode-compliant characters. Foundation types use `CharacterSet` to group characters together for searching operations, so that they can find any of a particular set of characters during a search. This type provides "copy-on-write" behavior, and is also bridged to the Objective-C `NSCharacterSet` class.

Members (52)

method · iOS 8.0+

isSuperset

TypeScript
isSuperset(other: CharacterSet): boolean
Swift declaration
func isSuperset(of other: CharacterSet) -> Bool

Returns true if `self` is a superset of `other`.

get · iOS 8.0+

description

TypeScript
get description(): string
Swift declaration
var description: String { get }

A textual representation of this instance. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(describing:)` initializer. This initializer works with any type, and uses the custom `description` property for types that conform to `CustomStringConvertible`: struct Point: CustomStringConvertible { let x: Int, y: Int var description: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(describing: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `description` property.

method · iOS 8.0+

subtracting

TypeScript
subtracting(other: CharacterSet): CharacterSet
Swift declaration
func subtracting(_ other: CharacterSet) -> CharacterSet

Returns a `CharacterSet` created by removing elements in `other` from `self`.

get · iOS 8.0+

whitespaces

TypeScript
static get whitespaces(): CharacterSet
Swift declaration
static var whitespaces: CharacterSet { get }

Returns a character set containing the characters in Unicode General Category Zs and `CHARACTER TABULATION (U+0009)`.

init · iOS 8.0+

init

TypeScript
static initCharactersIn(range: SDKHandle): CharacterSet
Swift declaration
init(charactersIn range: ClosedRange<Unicode.Scalar>)

Initialize with a closed range of integers. It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar` values, if that is what is desired.

init · iOS 8.0+

init

TypeScript
static initCharactersIn55101(string: string): CharacterSet
Swift declaration
init(charactersIn string: String)

Initialize with the characters in the given string. - parameter string: The string content to inspect for characters.

init · iOS 8.0+

init

TypeScript
static initCharactersIn97330(range: SDKHandle): CharacterSet
Swift declaration
init(charactersIn range: Range<Unicode.Scalar>)

Initialize with a range of integers. It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar` values, if that is what is desired.

method · iOS 8.0+

intersection

TypeScript
intersection(other: CharacterSet): CharacterSet
Swift declaration
func intersection(_ other: CharacterSet) -> CharacterSet

Returns an intersection of the `CharacterSet` with another `CharacterSet`.

get · iOS 8.0+

alphanumerics

TypeScript
static get alphanumerics(): CharacterSet
Swift declaration
static var alphanumerics: CharacterSet { get }

Returns a character set containing the characters in Unicode General Categories L*, M*, and N*.

get · iOS 8.0+

decimalDigits

TypeScript
static get decimalDigits(): CharacterSet
Swift declaration
static var decimalDigits: CharacterSet { get }

Returns a character set containing the characters in the category of Decimal Numbers.

get · iOS 8.0+

decomposables

TypeScript
static get decomposables(): CharacterSet
Swift declaration
static var decomposables: CharacterSet { get }

Returns a character set containing individual Unicode characters that can also be represented as composed character sequences (such as for letters with accents), by the definition of "standard decomposition" in version 3.2 of the Unicode character encoding standard.

init · iOS 8.0+

init

TypeScript
static initContentsOfFile(file: string): (CharacterSet) | null
Swift declaration
init?(contentsOfFile file: String)

Initialize with the contents of a file. Returns `nil` if there was an error reading the file. - parameter file: The file to read.

get · iOS 8.0+

urlHostAllowed

TypeScript
static get urlHostAllowed(): CharacterSet
Swift declaration
static var urlHostAllowed: CharacterSet { get }

Returns the character set for characters allowed in a host URL subcomponent.

get · iOS 8.0+

urlPathAllowed

TypeScript
static get urlPathAllowed(): CharacterSet
Swift declaration
static var urlPathAllowed: CharacterSet { get }

Returns the character set for characters allowed in a path URL component.

get · iOS 8.0+

urlUserAllowed

TypeScript
static get urlUserAllowed(): CharacterSet
Swift declaration
static var urlUserAllowed: CharacterSet { get }

Returns the character set for characters allowed in a user URL subcomponent.

get · iOS 8.0+

urlQueryAllowed

TypeScript
static get urlQueryAllowed(): CharacterSet
Swift declaration
static var urlQueryAllowed: CharacterSet { get }

Returns the character set for characters allowed in a query URL component.

get · iOS 8.0+

debugDescription

TypeScript
get debugDescription(): string
Swift declaration
var debugDescription: String { get }

A textual representation of this instance, suitable for debugging. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(reflecting:)` initializer. This initializer works with any type, and uses the custom `debugDescription` property for types that conform to `CustomDebugStringConvertible`: struct Point: CustomDebugStringConvertible { let x: Int, y: Int var debugDescription: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(reflecting: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `debugDescription` property.

method · iOS 8.0+

formIntersection

TypeScript
formIntersection(other: CharacterSet): void
Swift declaration
mutating func formIntersection(_ other: CharacterSet)

Sets the value to an intersection of the `CharacterSet` with another `CharacterSet`.

get · iOS 8.0+

lowercaseLetters

TypeScript
static get lowercaseLetters(): CharacterSet
Swift declaration
static var lowercaseLetters: CharacterSet { get }

Returns a character set containing the characters in Unicode General Category Ll.

get · iOS 8.0+

uppercaseLetters

TypeScript
static get uppercaseLetters(): CharacterSet
Swift declaration
static var uppercaseLetters: CharacterSet { get }

Returns a character set containing the characters in Unicode General Category Lu and Lt.

get · iOS 8.0+

controlCharacters

TypeScript
static get controlCharacters(): CharacterSet
Swift declaration
static var controlCharacters: CharacterSet { get }

Returns a character set containing the characters in Unicode General Category Cc and Cf.

get · iOS 8.0+

illegalCharacters

TypeScript
static get illegalCharacters(): CharacterSet
Swift declaration
static var illegalCharacters: CharacterSet { get }

Returns a character set containing values in the category of Non-Characters or that have not yet been defined in version 3.2 of the Unicode standard.

get · iOS 8.0+

nonBaseCharacters

TypeScript
static get nonBaseCharacters(): CharacterSet
Swift declaration
static var nonBaseCharacters: CharacterSet { get }

Returns a character set containing the characters in Unicode General Category M*.

get · iOS 8.0+

capitalizedLetters

TypeScript
static get capitalizedLetters(): CharacterSet
Swift declaration
static var capitalizedLetters: CharacterSet { get }

Returns a character set containing the characters in Unicode General Category Lt.

get · iOS 8.0+

urlFragmentAllowed

TypeScript
static get urlFragmentAllowed(): CharacterSet
Swift declaration
static var urlFragmentAllowed: CharacterSet { get }

Returns the character set for characters allowed in a fragment URL component.

get · iOS 8.0+

urlPasswordAllowed

TypeScript
static get urlPasswordAllowed(): CharacterSet
Swift declaration
static var urlPasswordAllowed: CharacterSet { get }

Returns the character set for characters allowed in a password URL subcomponent.

method · iOS 8.0+

symmetricDifference

TypeScript
symmetricDifference(other: CharacterSet): CharacterSet
Swift declaration
func symmetricDifference(_ other: CharacterSet) -> CharacterSet

Returns an exclusive or of the `CharacterSet` with another `CharacterSet`.

get · iOS 8.0+

bitmapRepresentation

TypeScript
get bitmapRepresentation(): ArrayBuffer
Swift declaration
@nonobjc var bitmapRepresentation: Data { get }

Returns a representation of the `CharacterSet` in binary format.

init · iOS 8.0+

init

TypeScript
static initBitmapRepresentation(data: ArrayBuffer): CharacterSet
Swift declaration
init(bitmapRepresentation data: Data)

Initialize with a bitmap representation. This method is useful for creating a character set object with data from a file or other external data source. - parameter data: The bitmap representation.

get · iOS 8.0+

punctuationCharacters

TypeScript
static get punctuationCharacters(): CharacterSet
Swift declaration
static var punctuationCharacters: CharacterSet { get }

Returns a character set containing the characters in Unicode General Category P*.

get · iOS 8.0+

whitespacesAndNewlines

TypeScript
static get whitespacesAndNewlines(): CharacterSet
Swift declaration
static var whitespacesAndNewlines: CharacterSet { get }

Returns a character set containing characters in Unicode General Category Z*, `U+000A ~ U+000D`, and `U+0085`.

method · iOS 8.0+

formSymmetricDifference

TypeScript
formSymmetricDifference(other: CharacterSet): void
Swift declaration
mutating func formSymmetricDifference(_ other: CharacterSet)

Sets the value to an exclusive or of the `CharacterSet` with another `CharacterSet`.

method · iOS 8.0+

union

TypeScript
union(other: CharacterSet): CharacterSet
Swift declaration
func union(_ other: CharacterSet) -> CharacterSet

Returns a union of the `CharacterSet` with another `CharacterSet`.

method · iOS 8.0+

insert

TypeScript
insertCharactersIn(range: SDKHandle): void
Swift declaration
mutating func insert(charactersIn range: ClosedRange<Unicode.Scalar>)

Insert a closed range of integer values in the `CharacterSet`. It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar` values, if that is what is desired.

method · iOS 8.0+

insert

TypeScript
insertCharactersIn17955(string: string): void
Swift declaration
mutating func insert(charactersIn string: String)

Insert the values from the specified string into the `CharacterSet`.

method · iOS 8.0+

insert

TypeScript
insertCharactersIn41656(range: SDKHandle): void
Swift declaration
mutating func insert(charactersIn range: Range<Unicode.Scalar>)

Insert a range of integer values in the `CharacterSet`. It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar` values, if that is what is desired.

method · iOS 8.0+

insert

TypeScript
insert(character: SDKHandle): { "inserted": boolean; "memberAfterInsert": SDKHandle }
Swift declaration
@discardableResult mutating func insert(_ character: Unicode.Scalar) -> (inserted: Bool, memberAfterInsert: Unicode.Scalar)

Insert a `Unicode.Scalar` representation of a character into the `CharacterSet`. `Unicode.Scalar` values are available on `Swift.String.UnicodeScalarView`.

method · iOS 8.0+

invert

TypeScript
invert(): void
Swift declaration
mutating func invert()

Invert the contents of the `CharacterSet`.

method · iOS 8.0+

remove

TypeScript
removeCharactersIn(range: SDKHandle): void
Swift declaration
mutating func remove(charactersIn range: ClosedRange<Unicode.Scalar>)

Remove a closed range of integer values from the `CharacterSet`.

method · iOS 8.0+

remove

TypeScript
removeCharactersIn81754(string: string): void
Swift declaration
mutating func remove(charactersIn string: String)

Remove the values from the specified string from the `CharacterSet`.

method · iOS 8.0+

remove

TypeScript
removeCharactersIn83469(range: SDKHandle): void
Swift declaration
mutating func remove(charactersIn range: Range<Unicode.Scalar>)

Remove a range of integer values from the `CharacterSet`.

method · iOS 8.0+

remove

TypeScript
remove(character: SDKHandle): (SDKHandle) | null
Swift declaration
@discardableResult mutating func remove(_ character: Unicode.Scalar) -> Unicode.Scalar?

Remove a `Unicode.Scalar` representation of a character from the `CharacterSet`. `Unicode.Scalar` values are available on `Swift.String.UnicodeScalarView`.

method · iOS 8.0+

update

TypeScript
update(character: SDKHandle): (SDKHandle) | null
Swift declaration
@discardableResult mutating func update(with character: Unicode.Scalar) -> Unicode.Scalar?

Insert a `Unicode.Scalar` representation of a character into the `CharacterSet`. `Unicode.Scalar` values are available on `Swift.String.UnicodeScalarView`.

get · iOS 8.0+

letters

TypeScript
static get letters(): CharacterSet
Swift declaration
static var letters: CharacterSet { get }

Returns a character set containing the characters in Unicode General Category L* & M*.

get · iOS 8.0+

symbols

TypeScript
static get symbols(): CharacterSet
Swift declaration
static var symbols: CharacterSet { get }

Returns a character set containing the characters in Unicode General Category S*.

method · iOS 8.0+

contains

TypeScript
contains(member: SDKHandle): boolean
Swift declaration
func contains(_ member: Unicode.Scalar) -> Bool

Test for membership of a particular `Unicode.Scalar` in the `CharacterSet`.

get · iOS 8.0+

inverted

TypeScript
get inverted(): CharacterSet
Swift declaration
@nonobjc var inverted: CharacterSet { get }

Returns an inverted copy of the receiver.

get · iOS 8.0+

newlines

TypeScript
static get newlines(): CharacterSet
Swift declaration
static var newlines: CharacterSet { get }

Returns a character set containing the newline characters (`U+000A ~ U+000D`, `U+0085`, `U+2028`, and `U+2029`).

method · iOS 8.0+

subtract

TypeScript
subtract(other: CharacterSet): void
Swift declaration
mutating func subtract(_ other: CharacterSet)

Sets the value to a `CharacterSet` created by removing elements in `other` from `self`.

method · iOS 8.0+

formUnion

TypeScript
formUnion(other: CharacterSet): void
Swift declaration
mutating func formUnion(_ other: CharacterSet)

Sets the value to a union of the `CharacterSet` with another `CharacterSet`.

method · iOS 8.0+

hasMember

TypeScript
hasMember(plane: number): boolean
Swift declaration
func hasMember(inPlane plane: UInt8) -> Bool

Returns true if the `CharacterSet` has a member in the specified plane. This method makes it easier to find the plane containing the members of the current character set. The Basic Multilingual Plane (BMP) is plane 0.

init · iOS 8.0+

init

TypeScript
static init(): CharacterSet
Swift declaration
init()

Initialize an empty instance.

Skipped declarations

No declarations were skipped in this snapshot.

All Foundation types →