I have a UnsafeMutablePointer pointing at a C string, I want to convert the bytes at this pointer to a Swift String, the data is a C string, so UTF8.
Is it possible to iterate byte by byte until NULL? Or some easier way?
CChar是Int8的别名,因此您可以在此处使用基于CChar的方法 。
let str = String(cString: pointer)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.