<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">No C strings import as UnsafePointer&lt;CChar&gt; for some reason; they all import as Int8</div><div class=""><br class=""></div><div class="">e.g.<br class="">public&nbsp;func&nbsp;pthread_setname_np(_:&nbsp;UnsafePointer&lt;Int8&gt;) -&gt;&nbsp;Int32</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 4, 2016, at 1:20 PM, Tony Parker via swift-corelibs-dev &lt;<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Luke,<div class=""><br class=""></div><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 2, 2016, at 8:28 PM, Luke Howard via swift-corelibs-dev &lt;<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Many Foundation APIs use Int8 instead of CChar when representing C strings, e.g.:</div><div class=""><div class="declaration" style="border: 0px; font-size: 10px; margin: 21px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Helvetica, Arial, sans-serif; line-height: normal; widows: 1; background-position: initial initial; background-repeat: initial initial;"><div class="Swift" style="border-width: 0px 0px 0px 5px; border-left-style: solid; border-left-color: rgb(205, 233, 244); margin: 10px 0px 21px; outline: 0px; padding: 4px 0px 2px 10px; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><div style="border: 0px; font-size: 1.4em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(65, 65, 65); line-height: 20.3px;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px 0px 15px; outline: 0px; padding: 0px 0px 6px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><span class="kt" style="border: 0px; font-size: 11.9px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145); background-position: initial initial; background-repeat: initial initial;">var</span>&nbsp;<span class="nl" style="border: 0px; font-size: 11.9px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;">UTF8String</span>:&nbsp;<span class="n" style="border: 0px; font-size: 11.9px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); background-position: initial initial; background-repeat: initial initial;"><a href="https://developer.apple.com/library/mac/documentation/Swift/Reference/Swift_UnsafePointer_Structure/index.html#//apple_ref/swift/struct/s:VSs13UnsafePointer" data-renderer-version="2" style="border: 0px; font-size: 11.9px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: inherit; text-decoration: none; background-position: initial initial; background-repeat: initial initial;" class="">UnsafePointer</a></span>&lt;<span class="n" style="border: 0px; font-size: 11.9px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(92, 38, 153); background-position: initial initial; background-repeat: initial initial;"><a href="https://developer.apple.com/library/mac/documentation/Swift/Reference/Swift_Int8_Structure/index.html#//apple_ref/swift/struct/s:VSs4Int8" data-renderer-version="2" style="border: 0px; font-size: 11.9px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: inherit; text-decoration: none; background-position: initial initial; background-repeat: initial initial;" class="">Int8</a></span>&gt; {&nbsp;<span class="kt" style="border: 0px; font-size: 11.9px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145); background-position: initial initial; background-repeat: initial initial;">get</span>&nbsp;}</code></div></div></div><div class="discussion" style="border: 0px; font-size: 10px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Helvetica, Arial, sans-serif; line-height: normal; widows: 1; background-position: initial initial; background-repeat: initial initial;"></div></div><div class="">I don’t know if/when Swift will be ported to a platform where the character type is unsigned but perhaps it would be good to update these to take CChar instead?</div><div class=""><br class=""></div><div class="">— Luke</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=U7z7oSqRMSwdl2rYt9JJ4zIFaeg4R-2FxExg9xndDuCbzMiJOLaugKlF6R6UjjO4nfcI15MmpaqdRW87F-2Ba-2B4kr29uhRU3y0244CyvTjjzIPgopMI9kob7tdFjCCfaS9VSYIQ04xJnpqsgN10OUDAoL9xTRWA9SrXwaYiQHdCRYPgAOn7GQ8hFys7lY-2FHbOHnmcRlYMkivVfi89-2F-2BlvOTOBK1GU6tCkKL6tFqaUi7YeOc-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div></div></blockquote><br class=""></div><div class="">I’m not really sure why it’s imported to Swift as an unsafe pointer to Int8 anyway. The Objective-C code uses char:</div></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">@property</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> (</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nullable</span><span style="font-variant-ligatures: no-common-ligatures;" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">readonly</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">__strong</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">const</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">char</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> *UTF8String </span><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class="">NS_RETURNS_INNER_POINTER</span><span style="font-variant-ligatures: no-common-ligatures;" class="">;<span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures" class="">// Convenience to return null-terminated UTF8 representation</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">- (</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nullable</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">instancetype</span><span style="font-variant-ligatures: no-common-ligatures" class="">)initWithUTF8String:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">const</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">char</span><span style="font-variant-ligatures: no-common-ligatures" class=""> *)nullTerminatedCString;</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">- Tony</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></span></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=0mkChau6XnFV-2FCNUik62L9ZaldD0W0ziOwj-2F3jLx369Z8CJUw9pXoPnylmfuyjJMAK5U6WaiudslFJTA1Lz6IjnX5zYhKODmRy7qQ3qxnzziUeGWnyBLmILTWVXyP9ykDMbDoDH9dV03ntOrF-2BQoZtyZ4rYC8ptA1SVuNoYQHjnC2cbyWq8UWtleWmS-2FjW1q5-2BilbU5ViqdlF1PrqnJMtrJQbfmuoXyUuLYbC3YIMDQ-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev<br class=""></div></blockquote></div><br class=""></body></html>