I have a c function which I access from a bridging header that returns a const char*
:
const char* get_c_string();
I then try to convert it to a Swift String:
let str = String.fromCString(UnsafePointer<Int8>(get_c_string()))
print(str)
... but it just prints garbage:
Optional("\u{14}\0\0")
I can find how to pass Swift string to C but not the other way around. How can I convert a const char*
to a Swift String?
Thanks!