How&#39;s the workload nowadays? You were pretty stressed last i checked. <span></span><br><br>On Monday 30 May 2016,  &lt;<a href="mailto:swift-users-request@swift.org">swift-users-request@swift.org</a>&gt; 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="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;swift-users@swift.org&#39;)">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" 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="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;swift-users-request@swift.org&#39;)">swift-users-request@swift.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;swift-users-owner@swift.org&#39;)">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="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;eskimo1@apple.com&#39;)">eskimo1@apple.com</a>&gt;<br>
To: Swift Users List &lt;<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;swift-users@swift.org&#39;)">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="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;D94A5001-BE92-44FB-ADB8-CE0D68E62323@apple.com&#39;)">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="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;swift-users@swift.org&#39;)">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" 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/" 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="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;swift-users@swift.org&#39;)">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" 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><br><br>-- <br><div dir="ltr"><div><div dir="ltr"><div>Jatin Arora</div><div>B.E. Information Technology</div><div>Netaji Subhas Institute of Technology</div></div></div></div><br>