0

I have clients where it uses both Python and Ruby to share the encoded strings between. Particularly ruby client will encode the string using base64_encode and Python client has to decoded that ruby based encoded string to parse the data. But when I tried to decode using base64 in python for the ruby base64 encoded string getting some wired error,

ERROR:

'utf-8' codec can't decode byte 0x9a in position 0: invalid start byte

But still seeing the message content as below which doesn't have proper format,

b'\x04\x08{\x0b:\x0cmsgtimel+\x07\xd6wcZ:\x0erequestid"%a6cbfedf3f195714a484asdc35bdc210:\thash"%ed9efcfda14asd902416151006c87324:\rsenderid"\x10test-server1:\tbody"k\x04\x08{\x08:\x0estatusmsg"\x07OK:\x0fstatuscodei\x00:\tdata{\n:\nerror0:\x0bstdout"\x11test-server-hostname\n:\x0bstderr"\x00:\x0boutput0:\rexitcodei\x00:\x10senderagent"\nshell'

NOTE: ruby client will decode the hash formatted string and the ruby version for some client is 1.8.7 and for some client is 1.9.3.

Karthi1234
  • 949
  • 1
  • 8
  • 28
  • I don't think Ruby 1.8 had Unicode support. Can you test with Ruby 2.x just to see if that works? Also, how are you passing the string between Ruby and Python? Would it help to encode the base 64 string in JSON or YAML when passing it to the other language's runtime? – Keith Bennett Jan 20 '18 at 18:00
  • If we can see the bit of ruby code that’s encoding to base 64 that might help as well, there are several ways to encode it from the standard library – alilland Jan 20 '18 at 18:29
  • Do you access to the string which Ruby will encode? Here is a similar question - https://stackoverflow.com/q/22216076/2096740 – arjun Jan 20 '18 at 19:17
  • @KeithBennett Am using STOMP protocol with ActiveMQ to pass the encoded byte. – Karthi1234 Jan 21 '18 at 08:04

0 Answers0