stringEncoding(for:encodingOptions:convertedString:usedLossyConversion:)
Returns the string encoding for the given data as detected by attempting to create a string according to the specified encoding options.
Declaration
class func stringEncoding(for data: Data, encodingOptions opts: [StringEncodingDetectionOptionsKey : Any]? = nil, convertedString string: AutoreleasingUnsafeMutablePointer<NSString?>?, usedLossyConversion: UnsafeMutablePointer<ObjCBool>?) -> UIntParameters
- data:
An
NSDataobject containing bytes in an encoding to be determined. - opts:
Options to use when attempting to determine the string encoding. See
String Encoding Detection Optionsfor a full list of supported options. - string:
If a string encoding could be determined, upon return contains an
NSStringobject constructed from data using the determined string encoding. - usedLossyConversion:
If a string encoding could be determined, upon return contains a
BOOLvalue corresponding to whether lossy conversion was used.
Return Value
An NSStringEncoding value, or 0 if a string encoding could not be determined.