diff --git a/Foundation/NSString.swift b/Foundation/NSString.swift index d54e5af369..68c2117927 100644 --- a/Foundation/NSString.swift +++ b/Foundation/NSString.swift @@ -297,7 +297,7 @@ open class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSC internal func _fastCStringContents(_ nullTerminated: Bool) -> UnsafePointer? { if type(of: self) == NSString.self || type(of: self) == NSMutableString.self { - if _storage._core.isASCII { + if _storage._guts._isContiguousASCII { return unsafeBitCast(_storage._core.startASCII, to: UnsafePointer.self) } } @@ -306,7 +306,7 @@ open class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSC internal var _fastContents: UnsafePointer? { if type(of: self) == NSString.self || type(of: self) == NSMutableString.self { - if !_storage._core.isASCII { + if _storage._guts._isContiguousUTF16 { return UnsafePointer(_storage._core.startUTF16) } } @@ -315,7 +315,7 @@ open class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSC internal var _encodingCantBeStoredInEightBitCFString: Bool { if type(of: self) == NSString.self || type(of: self) == NSMutableString.self { - return !_storage._core.isASCII + return !_storage._guts._isContiguousASCII } return false } @@ -858,7 +858,7 @@ extension NSString { public func getCString(_ buffer: UnsafeMutablePointer, maxLength maxBufferCount: Int, encoding: UInt) -> Bool { var used = 0 if type(of: self) == NSString.self || type(of: self) == NSMutableString.self { - if _storage._core.isASCII { + if _storage._guts._isContiguousASCII { used = min(self.length, maxBufferCount - 1) _storage._core.startASCII.withMemoryRebound(to: Int8.self, capacity: used) {