A little gift for my Linux friends: reading and writing strings from and to files I have tested on the IBM Sandbox but don’t have a Linux install. Let me know if this works for you. View the code on Gist. Share this:Click to share on Twitter (Opens in new window)Click to share on Facebook (Opens in new window) Related December 16, 2015 By erica Development, Swift 3 Comments Tweet this Post The evolution will be televised: Current and upcoming proposal reviewsThe evolution will be televised: Current and upcoming proposal reviews
3 Comments
tested on ubuntu 15.1. Works.
transcode() is a strange beast, but it would make stringFromBytes more general:
func stringFromBytes(bytes: UnsafeMutablePointer, count: Int) -> String {
var string = “”
let buffer = UnsafeMutableBufferPointer(start: bytes, count: count)
transcode(UTF8.self, UTF32.self, buffer.generate(),
{ string.append(UnicodeScalar($0)) }, stopOnError: true)
return string
}
[…] https://ericasadun.com/2015/12/16/a-little-gift-for-my-linux-friends-reading-and-writing-strings-from… (glibc-Beispiel) […]