@@ -42,22 +42,22 @@ extension String {
42
42
/// }
43
43
/// // Prints "Caf�"
44
44
///
45
- /// - Parameter cString : A pointer to a null-terminated UTF-8 code sequence.
46
- public init ( cString: UnsafePointer < CChar > ) {
47
- let len = UTF8 . _nullCodeUnitOffset ( in: cString )
45
+ /// - Parameter nullTerminatedUTF8 : A pointer to a null-terminated UTF-8 code sequence.
46
+ public init ( cString nullTerminatedUTF8 : UnsafePointer < CChar > ) {
47
+ let len = UTF8 . _nullCodeUnitOffset ( in: nullTerminatedUTF8 )
48
48
self = String . _fromUTF8Repairing (
49
- UnsafeBufferPointer ( start: cString . _asUInt8, count: len) ) . 0
49
+ UnsafeBufferPointer ( start: nullTerminatedUTF8 . _asUInt8, count: len) ) . 0
50
50
}
51
51
52
52
/// Creates a new string by copying the null-terminated UTF-8 data referenced
53
53
/// by the given pointer.
54
54
///
55
55
/// This is identical to `init(cString: UnsafePointer<CChar>)` but operates on
56
56
/// an unsigned sequence of bytes.
57
- public init ( cString: UnsafePointer < UInt8 > ) {
58
- let len = UTF8 . _nullCodeUnitOffset ( in: cString )
57
+ public init ( cString nullTerminatedUTF8 : UnsafePointer < UInt8 > ) {
58
+ let len = UTF8 . _nullCodeUnitOffset ( in: nullTerminatedUTF8 )
59
59
self = String . _fromUTF8Repairing (
60
- UnsafeBufferPointer ( start: cString , count: len) ) . 0
60
+ UnsafeBufferPointer ( start: nullTerminatedUTF8 , count: len) ) . 0
61
61
}
62
62
63
63
/// Creates a new string by copying and validating the null-terminated UTF-8
@@ -179,10 +179,10 @@ extension String {
179
179
@_specialize ( where Encoding == Unicode. UTF16 )
180
180
@inlinable // Fold away specializations
181
181
public init < Encoding: Unicode . Encoding > (
182
- decodingCString ptr : UnsafePointer < Encoding . CodeUnit > ,
182
+ decodingCString nullTerminatedCodeUnits : UnsafePointer < Encoding . CodeUnit > ,
183
183
as sourceEncoding: Encoding . Type
184
184
) {
185
- self = String . decodeCString ( ptr , as: sourceEncoding) !. 0
185
+ self = String . decodeCString ( nullTerminatedCodeUnits , as: sourceEncoding) !. 0
186
186
}
187
187
}
188
188
0 commit comments