title: Vertx event bus and encoding issues when encoding/decoding string to Kotlin ByteArray
body: <p>I'm using Kotlin and vertx. In my vertx app, I'm trying to send a ByteArray to another event consumer.</p>
  <p>To do this i'm converting it to a string, and then once its received in the 2nd handler I'm converting it back to a ByteArray but the objects aren't equal. They are very different and I have no idea why.</p>
  <p>My 2 event handlers are:</p>
  <pre><code>        eb.consumer&lt;JsonObject&gt;(&quot;epos.print.print-image-from-path&quot;) { message -&gt;
          GlobalScope.launch(vertx.dispatcher()) {
              var imagePath = message.body().get&lt;String&gt;(&quot;imagePath&quot;)
  
              var convertor = image2escpos.Image2ESCPOS()
              var bytes = convertor.printImage(imagePath)
  
              println( bytes.joinToString(&quot;&quot;) { String.format(&quot;%02X&quot;, (it.toInt() and 0xFF)) })
  
              queueJob(bytes.toTypedArray())
  
              temp1 = bytes
  
              eb.publish(&quot;epos.print.print-image-from-bitmap&quot;, json { obj(&quot;bytes&quot; to String(bytes)) })
          }
      }
  
      eb.consumer&lt;JsonObject&gt;(&quot;epos.print.print-image-from-bitmap&quot;) { message -&gt;
          GlobalScope.launch(vertx.dispatcher()) {
              var bytes = message.body().get&lt;String&gt;(&quot;bytes&quot;)
              var byteArray = bytes.toByteArray(StandardCharsets.UTF_8)
  
              println( byteArray.joinToString(&quot;&quot;) { String.format(&quot;%02X&quot;, (it.toInt() and 0xFF)) })
  
              println(&quot;OUTPUT&quot;)
              println(temp1)
              println(byteArray)
              println(temp1==byteArray)
          }
      }
  </code></pre>
  <p>and I have the private variable:
  <code>private lateinit var temp1:ByteArray</code> so that I can compare the 2 variables.</p>
  <p>I'm invoking the &quot;epos.print.print-image-from-path&quot; method by sending an event with a json body such as: <code>{ &quot;imagePath&quot; : &quot;/Users/XXXXXXX/Downloads/QR-Zed80.BMP&quot; }</code></p>
  <p>What am i missing when encoding/decoding objects. I'm not entirely sure how a string relates to a ByteArray but I need to pass a ByteArray between 2 handlers and String seem to be the only way on the event bus.</p>
  <p>Thanks for your help in advance!</p>
  <p>Rob</p>