Returns a Boolean value that indicates whether the receiver can be converted to a given encoding without loss of information.
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
YES if the receiver can be converted to
encoding without loss of information. Returns
NO if characters would have to be changed or deleted in the process of changing encodings.
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.
Working with Encodings
Returns a zero-terminated list of the encodings string objects support in the application’s environment.
Returns the C-string encoding assumed for any method accepting a C string as an argument.
NSData object containing a representation of the receiver encoded using a given encoding.
The fastest encoding to which the receiver may be converted without loss of information.
The smallest encoding to which the receiver can be converted without loss of information.
The following constants are provided by
NSString as possible string encodings.
NSString Handling Exception Names
These constants define the names of exceptions raised if
NSString cannot represent a string in a given encoding, or parse a string as a property list.