I have tried this method:
String.stringWithCString(cString: UnsafePointer<CChar>, encoding: NSStringEncoding)
But unfortunately, it only work with UnsafePointer<CChar>
. And I have no idea about how to convert UnsafePointer<CUnsignedChar>
to UnsafePointer<CChar>
.
Since Swift 3.0
let str = String(cString: UnsafePointer<CChar>(ptr))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With