How's the workload nowadays? You were pretty stressed last i checked. <span></span><br><br>On Monday 30 May 2016, <<a href="mailto:swift-users-request@swift.org">swift-users-request@swift.org</a>> 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, 'cvml', '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" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="javascript:;" onclick="_e(event, 'cvml', '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="javascript:;" onclick="_e(event, 'cvml', '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 "Re: Contents of swift-users digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Re: Simple text file I/O with Swift 3 (Quinn "The Eskimo!")<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Mon, 30 May 2016 09:11:41 +0100<br>
From: "Quinn \"The Eskimo!\"" <<a href="javascript:;" onclick="_e(event, 'cvml', 'eskimo1@apple.com')">eskimo1@apple.com</a>><br>
To: Swift Users List <<a href="javascript:;" onclick="_e(event, 'cvml', 'swift-users@swift.org')">swift-users@swift.org</a>><br>
Subject: Re: [swift-users] Simple text file I/O with Swift 3<br>
Message-ID: <<a href="javascript:;" onclick="_e(event, 'cvml', 'D94A5001-BE92-44FB-ADB8-CE0D68E62323@apple.com')">D94A5001-BE92-44FB-ADB8-CE0D68E62323@apple.com</a>><br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
<br>
On 28 May 2016, at 19:05, Ken Burgett via swift-users <<a href="javascript:;" onclick="_e(event, 'cvml', 'swift-users@swift.org')">swift-users@swift.org</a>> wrote:<br>
<br>
> 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>
<<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>><br>
<br>
Share and Enjoy<br>
--<br>
Quinn "The Eskimo!" <<a href="http://www.apple.com/developer/" target="_blank">http://www.apple.com/developer/</a>><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, 'cvml', 'swift-users@swift.org')">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>