我正在尝试直接在 Swift 中使用 libxml。现在我想得到一个 const unsigned char *
到一个字符串,但我不知道如何。有什么想法吗?
在 Objective-C 中它适用于
[NSString stringWithUTF8String:(const char*)nodePointer->name];
最佳答案
你试过吗:
let cString = CString(nodePointer.name)
let string = String.fromCString(cString)
在处理作为 UnsafePointer<CUnsignedChar>
返回的字符串值时,这对我有用当没有别的办法时。
关于swift - const unsigned char ptr (UnsafePointer<CUnsignedChar>) 到 String,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24169944/