Instance Method

canBeConverted(to:)

Returns a Boolean value that indicates whether the receiver can be converted to a given encoding without loss of information.

Declaration

func canBeConverted(to encoding: UInt) -> Bool

Parameters

encoding

A string encoding. For possible values, see NSStringEncoding.

Return Value

true if the receiver can be converted to encoding without loss of information. Returns false if characters would have to be changed or deleted in the process of changing encodings.

Discussion

If you plan to actually convert a string, the dataUsingEncoding:... methods return nil on failure, so you can avoid the overhead of invoking this method yourself by simply trying to convert the string.

See Also

Related Symbols

func data(using: UInt, allowLossyConversion: Bool)

Returns an NSData object containing a representation of the receiver encoded using a given encoding.