title: Binary string to human readable string
body: <p>I found some outdated information about this topic but none of the solutions were matching to the current Swift version. So I decided to ask the question again!</p>
  
  <ul>
  <li><a href="http://swift.oz-apps.com/2015/09/convert-binary-string-to-integer/" rel="nofollow noreferrer">http://swift.oz-apps.com/2015/09/convert-binary-string-to-integer/</a></li>
  <li><a href="http://sketchytech.blogspot.de/2015/08/from-binary-to-decimal-values-in-swift.html" rel="nofollow noreferrer">http://sketchytech.blogspot.de/2015/08/from-binary-to-decimal-values-in-swift.html</a></li>
  <li><a href="https://www.dotnetperls.com/convert-string-byte-array-swift" rel="nofollow noreferrer">https://www.dotnetperls.com/convert-string-byte-array-swift</a></li>
  </ul>
  
  <hr>
  
  <p>I got a string like this:</p>
  
  <pre><code>var string="abc"
  </code></pre>
  
  <p>...and with the following code I'm going to translate the string into binary code:</p>
  
  <pre><code>let binaryString = (string.data(using: .utf8, allowLossyConversion: false)?.reduce("") { (a, b) -&gt; String in a + String(b, radix: 2) })!
  </code></pre>
  
  <hr>
  
  <p>But how is it possible to decode an specific binary string back to a human readable string ??</p>
  
  <hr>
  
  <blockquote>
    <p>Get from <code>"110000111000101100011"</code> -----> "abc"</p>
  </blockquote>