0

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?

Peter Prographo
  • 1,141
  • 1
  • 10
  • 27

1 Answers1

2

CChar is an alias for Int8, so you can use CChar-based methods here.

let str = String(cString: pointer)
Rob Napier
  • 286,113
  • 34
  • 456
  • 610