I know questions like this exist on both Stack Overflow and elsewhere. But it seems to have evolved a lot as well.
Given a list of UInt8
(a swift byte array basically), what is the easiest/idiomatic way to covert it to a swift String
?
I'm particularly interested in the method that doesn't use NSData/NSString, since if Santa brings Swift to the world of Linux, it will undoubtedly be without the NS libraries, and I'd like to know how to do it in just Swift.
alternatively you can use
I actually ended up needing to do this for a stream of
UInt8
and was curious how hard utf8 decoding is. It's definitely not a one liner, but through the following direct implementation together:Xcode 8 • Swift 3
usage: