Skip to content

Commit e3ede3a

Browse files
committed
[stdlib] improve phrasing in some doc-comments
1 parent ae9892d commit e3ede3a

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

stdlib/public/core/CString.swift

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ extension String {
4242
/// }
4343
/// // Prints "Caf�"
4444
///
45-
/// - Parameter nullTerminatedUTF8: A pointer to a null-terminated UTF-8 code sequence.
45+
/// - Parameter nullTerminatedUTF8:
46+
/// A pointer to a null-terminated sequence of UTF-8 code units.
4647
public init(cString nullTerminatedUTF8: UnsafePointer<CChar>) {
4748
let len = UTF8._nullCodeUnitOffset(in: nullTerminatedUTF8)
4849
let buffer = UnsafeBufferPointer(start: nullTerminatedUTF8, count: len)
@@ -92,6 +93,9 @@ extension String {
9293
///
9394
/// This is identical to `init(cString: UnsafePointer<CChar>)` but operates on
9495
/// an unsigned sequence of bytes.
96+
///
97+
/// - Parameter nullTerminatedUTF8:
98+
/// A pointer to a null-terminated sequence of UTF-8 code units.
9599
public init(cString nullTerminatedUTF8: UnsafePointer<UInt8>) {
96100
let len = UTF8._nullCodeUnitOffset(in: nullTerminatedUTF8)
97101
self = String._fromUTF8Repairing(
@@ -152,7 +156,7 @@ extension String {
152156
/// // Prints "nil"
153157
///
154158
/// - Parameter nullTerminatedUTF8:
155-
/// A pointer to a null-terminated UTF-8 code sequence.
159+
/// A pointer to a null-terminated sequence of UTF-8 code units.
156160
@inlinable
157161
@_alwaysEmitIntoClient
158162
public init?(validatingCString nullTerminatedUTF8: UnsafePointer<CChar>) {
@@ -185,10 +189,11 @@ extension String {
185189
/// }
186190
/// // Prints "nil"
187191
///
188-
/// Note: This initializer is deprecated. Use
192+
/// Note: This initializer has been renamed. Use
189193
/// `String.init?(validatingCString:)` instead.
190194
///
191-
/// - Parameter cString: A pointer to a null-terminated UTF-8 code sequence.
195+
/// - Parameter cString:
196+
/// A pointer to a null-terminated sequence of UTF-8 code units.
192197
@available(swift, deprecated: 6, renamed: "String.init(validatingCString:)")
193198
public init?(validatingUTF8 cString: UnsafePointer<CChar>) {
194199
let len = UTF8._nullCodeUnitOffset(in: cString)
@@ -287,8 +292,8 @@ extension String {
287292
/// // Prints "Optional((result: "Caf�", repairsMade: true))"
288293
///
289294
/// - Parameters:
290-
/// - cString: A pointer to a null-terminated code sequence encoded in
291-
/// `encoding`.
295+
/// - cString: A pointer to a null-terminated sequence of
296+
/// code units encoded in `encoding`.
292297
/// - encoding: The Unicode encoding of the data referenced by `cString`.
293298
/// - isRepairing: Pass `true` to create a new string, even when the data
294299
/// referenced by `cString` contains ill-formed sequences. Ill-formed
@@ -397,13 +402,16 @@ extension String {
397402
return ("", false)
398403
}
399404

400-
/// Creates a string from the null-terminated sequence of bytes at the given
401-
/// pointer.
405+
/// Creates a new string by copying the null-terminated sequence of code units
406+
/// referenced by the given pointer.
407+
///
408+
/// If `nullTerminatedCodeUnits` contains ill-formed code unit sequences, this
409+
/// initializer replaces them with the Unicode replacement character
410+
/// (`"\u{FFFD}"`).
402411
///
403412
/// - Parameters:
404-
/// - nullTerminatedCodeUnits: A pointer to a sequence of contiguous code
405-
/// units in the encoding specified in `sourceEncoding`, ending just
406-
/// before the first zero code unit.
413+
/// - nullTerminatedCodeUnits: A pointer to a null-terminated sequence of
414+
/// code units encoded in `sourceEncoding`.
407415
/// - sourceEncoding: The encoding in which the code units should be
408416
/// interpreted.
409417
@_specialize(where Encoding == Unicode.UTF8)

0 commit comments

Comments
 (0)