<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div style="font-family:Arial;">On Thu, Mar 30, 2017, at 12:35 PM, FĂ©lix Cloutier via swift-evolution wrote:<br></div>
<blockquote type="cite"><div>I don't have much non-nitpick issues that I greatly care about; I'm in favor of this.<br></div>
<div><br></div>
<div>My only request: it's currently painful to create a String from a fixed-size C array. For instance, if I have a pointer to a `struct foo { char name[16]; }` in Swift where the last character doesn't have to be a NUL, it's hard to create a String from it. Real-world examples of this are Mach-O LC_SEGMENT and LC_SEGMENT_64 commands.<br></div>
<div style="font-family:Arial;"><br></div>
<div><br></div>
<div>The&nbsp;<a href="http://stackoverflow.com/a/27456220/251153">generally-accepted wisdom</a>&nbsp;is that you take a pointer to the CChar tuple that represents the fixed-size array, but this still requires the string to be NUL-terminated. What do we think of an additional init(cString:) overload that takes an UnsafeBufferPointer and reads up to the first NUL or the end of the buffer, whichever comes first?<br></div>
</blockquote><div style="font-family:Arial;"><br></div>
<div style="font-family:Arial;">Today's String already supports this through `String.decodeCString(_:as:repairingInvalidCodeUnits:)`, passing a buffer pointer.<br></div>
<div style="font-family:Arial;"><div style="font-family:Arial;"><div style="font-family:Arial;"><br></div>
</div>
<div id="sig40804545"><div class="signature"><span class="font" style="font-family:arial, sans-serif, sans-serif">Best,</span><br></div>
<div class="signature"><span class="font" style="font-family:arial, sans-serif, sans-serif">&nbsp; Zachary Waldowski</span><br></div>
<div class="signature"><span class="font" style="font-family:arial, sans-serif, sans-serif">&nbsp;&nbsp;</span><a href="mailto:zach@waldowski.me"><span class="font" style="font-family:arial, sans-serif, sans-serif">zach@waldowski.me</span></a><br></div>
</div>
<div><div style="font-family:Arial;"><br></div>
</div>
<div><div style="font-family:Arial;"><br></div>
</div>
</div>
<div style="font-family:Arial;"><br></div>
</body>
</html>