@@ -52,6 +52,19 @@ extension String {
52
52
}
53
53
}
54
54
55
+ /// Creates a new string by copying the null-terminated UTF-8 data referenced
56
+ /// by the given array.
57
+ ///
58
+ /// If `cString` contains ill-formed UTF-8 code unit sequences, this
59
+ /// initializer replaces them with the Unicode replacement character
60
+ /// (`"\u{FFFD}"`).
61
+ ///
62
+ /// Note: This initializer is deprecated. Use the initializer
63
+ /// `String.init(decoding: array, as: UTF8.self)` instead,
64
+ /// remembering that "\0" is a valid character in Swift.
65
+ ///
66
+ /// - Parameter nullTerminatedUTF8:
67
+ /// An array containing a null-terminated sequence of UTF-8 code units.
55
68
@inlinable
56
69
@_alwaysEmitIntoClient
57
70
@available ( swift, deprecated: 6 , message: " Use String(decoding: array, as: UTF8.self) instead " )
@@ -102,6 +115,18 @@ extension String {
102
115
UnsafeBufferPointer ( start: nullTerminatedUTF8, count: len) ) . 0
103
116
}
104
117
118
+ /// Creates a new string by copying the null-terminated UTF-8 data referenced
119
+ /// by the given array.
120
+ ///
121
+ /// This is identical to `init(cString: [CChar])` but operates on
122
+ /// an unsigned sequence of bytes.
123
+ ///
124
+ /// Note: This initializer is deprecated. Use the initializer
125
+ /// `String.init(decoding: array, as: UTF8.self)` instead,
126
+ /// remembering that "\0" is a valid character in Swift.
127
+ ///
128
+ /// - Parameter nullTerminatedUTF8:
129
+ /// An array containing a null-terminated UTF-8 code unit sequence.
105
130
@inlinable
106
131
@_alwaysEmitIntoClient
107
132
@available ( swift, deprecated: 6 , message: " Use String(decoding: array, as: UTF8.self) instead " )
@@ -205,6 +230,18 @@ extension String {
205
230
self = str
206
231
}
207
232
233
+ /// Creates a new string by copying and validating the null-terminated UTF-8
234
+ /// data referenced by the given array.
235
+ ///
236
+ /// This initializer does not try to repair ill-formed UTF-8 code unit
237
+ /// sequences. If any are found, the result of the initializer is `nil`.
238
+ ///
239
+ /// Note: This initializer is deprecated. Use the initializer
240
+ /// `String.init?(validating: array, as: UTF8.self)` instead,
241
+ /// remembering that "\0" is a valid character in Swift.
242
+ ///
243
+ /// - Parameter nullTerminatedUTF8:
244
+ /// An array containing a null-terminated sequence of UTF-8 code units.
208
245
@inlinable
209
246
@_alwaysEmitIntoClient
210
247
@available ( swift, deprecated: 6 , message: " Use String(validating: array, as: UTF8.self) instead " )
@@ -221,6 +258,18 @@ extension String {
221
258
self = string
222
259
}
223
260
261
+ /// Creates a new string by copying and validating the null-terminated UTF-8
262
+ /// data referenced by the given array.
263
+ ///
264
+ /// This initializer does not try to repair ill-formed UTF-8 code unit
265
+ /// sequences. If any are found, the result of the initializer is `nil`.
266
+ ///
267
+ /// Note: This initializer is deprecated. Use the initializer
268
+ /// `String.init?(validating: array, as: UTF8.self)` instead,
269
+ /// remembering that "\0" is a valid character in Swift.
270
+ ///
271
+ /// - Parameter cString:
272
+ /// An array containing a null-terminated sequence of UTF-8 code units.
224
273
@inlinable
225
274
@_alwaysEmitIntoClient
226
275
@available ( swift, deprecated: 6 , message: " Use String(validating: array, as: UTF8.self) instead " )
@@ -424,6 +473,22 @@ extension String {
424
473
self = String . decodeCString ( nullTerminatedCodeUnits, as: sourceEncoding) !. 0
425
474
}
426
475
476
+ /// Creates a new string by copying the null-terminated sequence of code units
477
+ /// referenced by the given array.
478
+ ///
479
+ /// If `nullTerminatedCodeUnits` contains ill-formed code unit sequences, this
480
+ /// initializer replaces them with the Unicode replacement character
481
+ /// (`"\u{FFFD}"`).
482
+ ///
483
+ /// Note: This initializer is deprecated. Use the initializer
484
+ /// `String.init(decoding: array, as: Encoding.self)` instead,
485
+ /// remembering that "\0" is a valid character in Swift.
486
+ ///
487
+ /// - Parameters:
488
+ /// - nullTerminatedCodeUnits: An array containing a null-terminated
489
+ /// sequence of code units encoded in `sourceEncoding`.
490
+ /// - sourceEncoding: The encoding in which the code units should be
491
+ /// interpreted.
427
492
@inlinable
428
493
@_alwaysEmitIntoClient
429
494
@available ( swift, deprecated: 6 , message: " Use String(decoding: array, as: Encoding.self) instead " )
0 commit comments