File tree Expand file tree Collapse file tree 2 files changed +3
-15
lines changed Expand file tree Collapse file tree 2 files changed +3
-15
lines changed Original file line number Diff line number Diff line change @@ -1221,18 +1221,6 @@ extension NSString {
1221
1221
free ( bytes)
1222
1222
}
1223
1223
}
1224
-
1225
- public convenience init ? ( CString nullTerminatedCString: UnsafePointer < Int8 > , encoding: UInt ) {
1226
- guard let cf = CFStringCreateWithCString ( kCFAllocatorSystemDefault, nullTerminatedCString, CFStringConvertNSStringEncodingToEncoding ( encoding) ) else {
1227
- return nil
1228
- }
1229
- var str : String ?
1230
- if String . _conditionallyBridgeFromObjectiveC ( cf. _nsObject, result: & str) {
1231
- self . init ( str!)
1232
- } else {
1233
- return nil
1234
- }
1235
- }
1236
1224
1237
1225
public convenience init ( contentsOf url: URL , encoding enc: UInt ) throws {
1238
1226
let readResult = try NSData ( contentsOf: url, options: [ ] )
Original file line number Diff line number Diff line change @@ -265,21 +265,21 @@ class TestNSString : XCTestCase {
265
265
266
266
func test_FromNullTerminatedCStringInASCII( ) {
267
267
let bytes = mockASCIIStringBytes + [ 0x00 ]
268
- let string = NSString ( CString : bytes. map { Int8 ( bitPattern: $0) } , encoding: String . Encoding. ascii. rawValue)
268
+ let string = NSString ( cString : bytes. map { Int8 ( bitPattern: $0) } , encoding: String . Encoding. ascii. rawValue)
269
269
XCTAssertNotNil ( string)
270
270
XCTAssertTrue ( string? . isEqual ( to: mockASCIIString) ?? false )
271
271
}
272
272
273
273
func test_FromNullTerminatedCStringInUTF8( ) {
274
274
let bytes = mockUTF8StringBytes + [ 0x00 ]
275
- let string = NSString ( CString : bytes. map { Int8 ( bitPattern: $0) } , encoding: String . Encoding. utf8. rawValue)
275
+ let string = NSString ( cString : bytes. map { Int8 ( bitPattern: $0) } , encoding: String . Encoding. utf8. rawValue)
276
276
XCTAssertNotNil ( string)
277
277
XCTAssertTrue ( string? . isEqual ( to: mockUTF8String) ?? false )
278
278
}
279
279
280
280
func test_FromMalformedNullTerminatedCStringInUTF8( ) {
281
281
let bytes = mockMalformedUTF8StringBytes + [ 0x00 ]
282
- let string = NSString ( CString : bytes. map { Int8 ( bitPattern: $0) } , encoding: String . Encoding. utf8. rawValue)
282
+ let string = NSString ( cString : bytes. map { Int8 ( bitPattern: $0) } , encoding: String . Encoding. utf8. rawValue)
283
283
XCTAssertNil ( string)
284
284
}
285
285
You can’t perform that action at this time.
0 commit comments