<div dir="ltr">Is there a way to format the text in the following link that appeared in today&#39;s digest?  The code toward the bottom is all run together.  I would edit to correct it if that were possible.<div>Thanks!</div><div><br><span style="font-size:12.8px">&lt;</span><a href="http://article.gmane.org/gmane.comp.lang.swift.user/1943" rel="noreferrer" target="_blank" style="font-size:12.8px">http://article.gmane.org/gmane.comp.lang.swift.user/1943</a><span style="font-size:12.8px">&gt;</span><br style="font-size:12.8px"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 30, 2016 at 12:00 PM,  <span dir="ltr">&lt;<a href="mailto:swift-users-request@swift.org" target="_blank">swift-users-request@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send swift-users mailing list submissions to<br>
        <a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
or, via email, send a message with subject or body &#39;help&#39; to<br>
        <a href="mailto:swift-users-request@swift.org">swift-users-request@swift.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:swift-users-owner@swift.org">swift-users-owner@swift.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of swift-users digest...&quot;<br>
<br>
<br>
Today&#39;s Topics:<br>
<br>
   1. Re: Simple text file I/O with Swift 3 (Quinn &quot;The Eskimo!&quot;)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Mon, 30 May 2016 09:11:41 +0100<br>
From: &quot;Quinn \&quot;The Eskimo!\&quot;&quot; &lt;<a href="mailto:eskimo1@apple.com">eskimo1@apple.com</a>&gt;<br>
To: Swift Users List &lt;<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>&gt;<br>
Subject: Re: [swift-users] Simple text file I/O with Swift 3<br>
Message-ID: &lt;<a href="mailto:D94A5001-BE92-44FB-ADB8-CE0D68E62323@apple.com">D94A5001-BE92-44FB-ADB8-CE0D68E62323@apple.com</a>&gt;<br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
<br>
On 28 May 2016, at 19:05, Ken Burgett via swift-users &lt;<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>&gt; wrote:<br>
<br>
&gt; print(buf)<br>
<br>
<br>
The trick here is to replace the above line with:<br>
<br>
    print(String(validatingUTF8: buf))<br>
<br>
`fgets` sets up `buf` to hold a C string, so you have to convert it to a Swift string.  How do you do this depends on the encoding of the bytes.  If you expect the C string to be UTF-8, then `String(validatingUTF8:)` is the way to go.<br>
<br>
IMPORTANT: This conversion can fail, which is why the above will print a bunch of optional strings, and you will have to decide what to your program should do when it does.<br>
<br>
                   *                   *                   *<br>
<br>
btw This question came up recently.  See the thread for other suggestions about how to handle it.<br>
<br>
&lt;<a href="http://article.gmane.org/gmane.comp.lang.swift.user/1943" rel="noreferrer" target="_blank">http://article.gmane.org/gmane.comp.lang.swift.user/1943</a>&gt;<br>
<br>
Share and Enjoy<br>
--<br>
Quinn &quot;The Eskimo!&quot;                    &lt;<a href="http://www.apple.com/developer/" rel="noreferrer" target="_blank">http://www.apple.com/developer/</a>&gt;<br>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware<br>
<br>
<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
<br>
<br>
End of swift-users Digest, Vol 6, Issue 28<br>
******************************************<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">John Myers<div>Mathematics and Computer Science Teacher</div><div><br></div><div>------------------------------------------------------------------</div><div><a href="mailto:myersj@shawanoschools.com" target="_blank">myersj@shawanoschools.com</a></div><div><br></div></div></div>
</div></div></div>