@@ -186,11 +186,17 @@ extension String {
186
186
///
187
187
/// - Parameter nullTerminatedUTF8:
188
188
/// A pointer to a null-terminated sequence of UTF-8 code units.
189
- @inlinable
190
- @_alwaysEmitIntoClient
189
+ @_silgen_name ( " $sSS14validatingUTF8SSSgSPys4Int8VG_tcfC " )
191
190
public init ? ( validatingCString nullTerminatedUTF8: UnsafePointer < CChar > ) {
192
- // FIXME: https://github.com/apple/swift/issues/68433 (rdar://115296219)
193
- self . init ( validatingUTF8: nullTerminatedUTF8)
191
+ let len = UTF8 . _nullCodeUnitOffset ( in: nullTerminatedUTF8)
192
+ let str = nullTerminatedUTF8. withMemoryRebound (
193
+ to: UInt8 . self,
194
+ capacity: len,
195
+ { String . _tryFromUTF8 ( UnsafeBufferPointer ( start: $0, count: len) ) }
196
+ )
197
+ guard let str else { return nil }
198
+
199
+ self = str
194
200
}
195
201
196
202
/// Creates a new string by copying and validating the null-terminated UTF-8
@@ -223,15 +229,12 @@ extension String {
223
229
///
224
230
/// - Parameter cString:
225
231
/// A pointer to a null-terminated sequence of UTF-8 code units.
232
+ @inlinable
233
+ @_alwaysEmitIntoClient
226
234
@available ( swift, deprecated: 6 , renamed: " String.init(validatingCString:) " )
235
+ @_silgen_name ( " _swift_se0405_String_validatingUTF8 " )
227
236
public init ? ( validatingUTF8 cString: UnsafePointer < CChar > ) {
228
- let len = UTF8 . _nullCodeUnitOffset ( in: cString)
229
- guard let str = cString. withMemoryRebound ( to: UInt8 . self, capacity: len, {
230
- String . _tryFromUTF8 ( UnsafeBufferPointer ( start: $0, count: len) )
231
- } )
232
- else { return nil }
233
-
234
- self = str
237
+ self . init ( validatingCString: cString)
235
238
}
236
239
237
240
/// Creates a new string by copying and validating the null-terminated UTF-8
0 commit comments