<div dir="ltr">I think it would be more appropriate to use `init(utf8: UnsafeBufferPointer<UInt8>)`, which comprises both a base pointer and a length.<div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Jacob Bandes-Storch<br></div></div></div></div>
<br><div class="gmail_quote">On Fri, Jan 8, 2016 at 9:58 PM, Charles Kissinger via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">The String initializer that would actually be of most value to me would be:<div><br></div><div>String.init(utf8: UnsafePointer<UInt8>, length: Int)</div><div><br></div><div>as long as it is as fast (preferably faster) than String.fromCString() and doesn’t require bridging to NSString. A similar initializer is available for NSString, but as Zach indicated in his link, using it is slow.</div><div><br></div><div>Several other initializers, including the one you showed, would be useful, as long as they are performant.</div><div><br></div><div>—CK</div><div><br></div><div><div><blockquote type="cite"><div><div class="h5"><div>On Jan 8, 2016, at 9:04 PM, 品雪 via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br></div></div><div><div><div class="h5"><div dir="ltr">Sorry, I didn't get it, are you talking about:<div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">var</span> bytes : [<span style="color:rgb(112,61,170)">UInt8</span>] = [<span style="color:rgb(39,42,216)">65</span>, <span style="color:rgb(39,42,216)">66</span>, <span style="color:rgb(39,42,216)">67</span>, <span style="color:rgb(39,42,216)">68</span>, <span style="color:rgb(39,42,216)">69</span>, <span style="color:rgb(39,42,216)">70</span>];</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">var</span> s = <span style="color:rgb(112,61,170)">String</span>.<span style="color:rgb(187,44,162)">init</span>(bytes: <span style="color:rgb(79,129,135)">bytes</span>, encoding: <span style="color:rgb(112,61,170)">NSUTF8StringEncoding</span>)</div><div><br></div><div>?</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 9, 2016 at 8:22 AM, T.J. Usiyan via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">I support this change as well.<div><br></div><div>TJ</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 8, 2016 at 6:06 PM, Guillaume Lessard via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Complete agreement from me. I would like to see a String constructor from a Sequence of code units.<br>
Also, why is String.fromCString() a factory function rather than a fallible constructor?<br>
<br>
Guillaume Lessard<br>
<div><div><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>
</div></div></blockquote></div><br></div>
</div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=zv-2Fta8zZnJ-2BWwISX5RHdd79su-2FjoebtLz43a4s-2BYOw1YUwmckQZetWwzLJetjkg0VLSsYeNrva793asxb2J13O0wwqKRDxIuX1zxa3yr9JEBz1QkaGutYcMvEh8twd8aHreITfNteRdIaIIXFmIHam7GtGEq3rInmgnYBA12e6I8pUV52QJZ1uhb-2F70FWI-2BSizejFgZy-2BY-2Blox8jB6myHqQON-2BWIOMwsJohYKvreruE-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important">
<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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr">Best Regards!<br><br>Yang Wu<br>--------------------------------------------------------<br>Location: Pudong, Shanghai, China.<br>EMail : <a href="mailto:pinxue@gmail.com" target="_blank">pinxue@gmail.com</a><br>Website: <a href="http://www.time2change.mobi/" target="_blank">http://www.time2change.mobi</a> <a href="http://rockplayer.com/" target="_blank">http://rockplayer.com</a><br>Twitter/Weibo : @pinxue<br><a href="http://www.pinxue.net/" target="_blank"></a></div></div>
</div></div></div>
</div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=F5lQLlMRbBDxNsThVg1FdaN-2FDA1CiFgV-2FmWJt88lR-2Fpi3AyL-2BYPfTLOWQEDSTRbaIzBgmlUrJotWJuXiWb1uR7Sg6jpwJiAkj1xrmCz-2FdEUGwVQianLN8REjX9vG-2Fnq0LDW8rmcSG-2BwGVpGANJ0u3DV4c1uZTOLxurng76JzxwcBfIYXhPubJOJiKA-2BpVcmyhWbkVort64NR6yR5Y-2B8JOQ-3D-3D" alt="" width="1" height="1" border="0" style="min-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">
_______________________________________________<span class=""><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" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></span></div></blockquote></div><br></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=P-2BsYbBZHRBuLDBJaL4DIKDNfkkjpROowTyRAObV11qwmk8XxeZ-2FbKmNh-2BuB031-2Fmj8KdbZBHf-2F-2FkH4rzEtOk29ufqufodEp-2Bql5wAHJZUpQERyRW-2F7FU97XTF-2FPG0WQswylNbPIOv1gWHx7wELHeatGhen8p-2F2ZCmrgspPYMnho-2F7Fyla0Pkw-2Bc8jzHMuasC6NemqTS2a8UPPi0CsE7iXbOEl2SgQfu0i-2FfvR4AiJ14-3D" alt="" width="1" height="1" border="0" style="min-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">
</div>
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">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>
<br></blockquote></div><br></div></div>