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