Ben, while I&#39;m broadly sympathetic to making CChar work more widely, if I recall correctly this was a rather complex discussion topic you&#39;re raising again. Besides the unprecedented name (Unsigned is never spelled out at the moment), I wonder if all the other salient issues involved are best left for a wider discussion than is possible here, especially since the pitch and proposal have been limited to two properties.<br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 27, 2016 at 07:33 Ben Rimmington via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
&gt; On 25 Jul 2016, at 15:27, Ben Rimmington wrote:<br>
&gt;<br>
&gt; &lt;<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0134-rename-string-properties.md" rel="noreferrer" target="_blank">https://github.com/apple/swift-evolution/blob/master/proposals/0134-rename-string-properties.md</a>&gt;<br>
&gt;<br>
&gt; My suggestion for SE-0134 is to use the `utf8CString` name, overloading for CSignedChar and CUnsignedChar:<br>
&gt;<br>
&gt;       &lt;<a href="https://github.com/apple/swift/blob/master/stdlib/public/core/CString.swift" rel="noreferrer" target="_blank">https://github.com/apple/swift/blob/master/stdlib/public/core/CString.swift</a>&gt;<br>
&gt;<br>
&gt;       extension String {<br>
&gt;       - init(cString: UnsafePointer&lt;CChar&gt;)<br>
&gt;       - init(cString: UnsafePointer&lt;UInt8&gt;)<br>
&gt;       - init?(validatingUTF8 cString: UnsafePointer&lt;CChar&gt;)<br>
&gt;<br>
&gt;       + init(utf8CString: UnsafePointer&lt;CSignedChar&gt;)<br>
&gt;       + init(utf8CString: UnsafePointer&lt;CUnsignedChar&gt;)<br>
&gt;       + init?(validatingUTF8CString: UnsafePointer&lt;CSignedChar&gt;)<br>
&gt;       + init?(validatingUTF8CString: UnsafePointer&lt;CUnsignedChar&gt;)<br>
&gt;       }<br>
&gt;<br>
&gt; The properties would change to methods, overloaded by return type:<br>
&gt;<br>
&gt;       &lt;<a href="https://github.com/apple/swift/blob/master/stdlib/public/core/StringUTF8.swift" rel="noreferrer" target="_blank">https://github.com/apple/swift/blob/master/stdlib/public/core/StringUTF8.swift</a>&gt;<br>
&gt;<br>
&gt;       extension String {<br>
&gt;       - var nulTerminatedUTF8CString: ContiguousArray&lt;CChar&gt;<br>
&gt;       - var nulTerminatedUTF8: ContiguousArray&lt;UTF8.CodeUnit&gt;<br>
&gt;<br>
&gt;       + func utf8CString() -&gt; ContiguousArray&lt;CSignedChar&gt;<br>
&gt;       + func utf8CString() -&gt; ContiguousArray&lt;CUnsignedChar&gt;<br>
&gt;       }<br>
&gt;<br>
&gt; ## NOTES ##<br>
&gt;<br>
&gt; UTF8.CodeUnit is defined as UInt8, and CChar is currently defined as Int8:<br>
&gt;<br>
&gt;       &lt;<a href="https://github.com/apple/swift/blob/master/stdlib/public/core/CTypes.swift" rel="noreferrer" target="_blank">https://github.com/apple/swift/blob/master/stdlib/public/core/CTypes.swift</a>&gt;<br>
&gt;<br>
&gt;       /// The C &#39;char&#39; type.<br>
&gt;       ///<br>
&gt;       /// This will be the same as either `CSignedChar` (in the common<br>
&gt;       /// case) or `CUnsignedChar`, depending on the platform.<br>
&gt;       public typealias CChar = Int8<br>
&gt;<br>
&gt;       /// The C &#39;signed char&#39; type.<br>
&gt;       public typealias CSignedChar = Int8<br>
&gt;<br>
&gt;       /// The C &#39;unsigned char&#39; type.<br>
&gt;       public typealias CUnsignedChar = UInt8<br>
&gt;<br>
&gt; There&#39;s an abandoned proposal to update CChar:<br>
&gt;<br>
&gt;       &lt;<a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/7925/focus=8158" rel="noreferrer" target="_blank">http://thread.gmane.org/gmane.comp.lang.swift.evolution/7925/focus=8158</a>&gt;<br>
&gt;<br>
&gt;       &lt;<a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/8419" rel="noreferrer" target="_blank">http://thread.gmane.org/gmane.comp.lang.swift.evolution/8419</a>&gt;<br>
&gt;<br>
&gt; String.init(cString: UnsafePointer&lt;UInt8&gt;) and nulTerminatedUTF8CString were added by SE-0107:<br>
&gt;<br>
&gt;       &lt;<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0107-unsaferawpointer.md#cstring-conversion" rel="noreferrer" target="_blank">https://github.com/apple/swift-evolution/blob/master/proposals/0107-unsaferawpointer.md#cstring-conversion</a>&gt;<br>
&gt;<br>
&gt;       &lt;<a href="https://github.com/apple/swift/commit/c7aa8284c905a73959ad69255cb56c38db80d039" rel="noreferrer" target="_blank">https://github.com/apple/swift/commit/c7aa8284c905a73959ad69255cb56c38db80d039</a>&gt;<br>
&gt;<br>
&gt; Foundation.NSString uses the `utf8String` name instead:<br>
&gt;<br>
&gt;       &lt;<a href="https://developer.apple.com/reference/foundation/nsstring/1412128-init" rel="noreferrer" target="_blank">https://developer.apple.com/reference/foundation/nsstring/1412128-init</a>&gt;<br>
&gt;<br>
&gt;       &lt;<a href="https://developer.apple.com/reference/foundation/nsstring/1411189-utf8string" rel="noreferrer" target="_blank">https://developer.apple.com/reference/foundation/nsstring/1411189-utf8string</a>&gt;<br>
<br>
&lt;<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0134-rename-string-properties.md" rel="noreferrer" target="_blank">https://github.com/apple/swift-evolution/blob/master/proposals/0134-rename-string-properties.md</a>&gt;<br>
<br>
There&#39;s another method for SE-0134 which could be renamed or removed:<br>
<br>
        &lt;<a href="https://github.com/apple/swift/blob/master/stdlib/public/core/LifetimeManager.swift" rel="noreferrer" target="_blank">https://github.com/apple/swift/blob/master/stdlib/public/core/LifetimeManager.swift</a>&gt;<br>
<br>
        extension String {<br>
        - func withCString&lt;Result&gt;(<br>
        -   _ body: @noescape (UnsafePointer&lt;Int8&gt;) throws -&gt; Result<br>
        - ) rethrows -&gt; Result<br>
<br>
        + func withUTF8CString&lt;Result&gt;(<br>
        +   _ body: @noescape (UnsafePointer&lt;CSignedChar&gt;) throws -&gt; Result<br>
        + ) rethrows -&gt; Result<br>
<br>
        + func withUTF8CString&lt;Result&gt;(<br>
        +   _ body: @noescape (UnsafePointer&lt;CUnsignedChar&gt;) throws -&gt; Result<br>
        + ) rethrows -&gt; Result<br>
        }<br>
<br>
The overloads (CSignedChar and CUnsignedChar) are needed if CChar will become UInt8 on some platforms.<br>
<br>
-- Ben<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>