Byte encoding for goal app command output

If I run the command:

goal app read --app-id 1127413236 --global

I get back the global state of the app, which includes the field:

"admin_address": { "tb": "+\ufffd\ufffdI\ufffd\ufffd\u0000\ufffd\u0011\ufffd\ufffd\u0011b\ufffdm\ufffd\ufffd>GO\ufffd\ufffdu3\ufffd\ufffd\ufffd#6\ufffd(H", "tt": 1 },

According to algoexplorer
https://algoexplorer.io/application/1127413236
that byte string represents FOPPYSPD3UANWENNYAIWFSLN4DLD4R2P4KVXKM5GWDQSGNU4FBEH2Y2K5M

What byte encoding is the goal app command output using to represent that value?

I would suggest to use –guess-format with that command.

goal app read --app-id 1127413236 --global --guess-format

This way it formats the address as a string.

That’s a cool option I didn’t know, I still wonder though how you go from
"FOPPYSPD3UANWENNYAIWFSLN4DLD4R2P4KVXKM5GWDQSGNU4FBEH2Y2K5M"
to
"+\ufffd\ufffdI\ufffd\ufffd\u0000\ufffd\u0011\ufffd\ufffd\u0011b\ufffdm\ufffd\ufffd>GO\ufffd\ufffdu3\ufffd\ufffd\ufffd#6\ufffd(H"

I guess I’ll have to go read the code :slight_smile:

I’m sure it is not a proper encoding. It has 32 unicode characters, and some of them are correct bytes from the decoded address:
algosdk.encoding.decode_address('FOPPYSPD3UANWENNYAIWFSLN4DLD4R2P4KVXKM5GWDQSGNU4FBEH2Y2K5M')
b'+\x9e\xfcI\xe3\xdd\x00\xdb\x11\xad\xc0\x11b\xc9m\xe0\xd6>GO\xe2\xabu3\xa6\xb0\xe1#6\x9c(H'

But the majority of the symbols are just \ufffd which is a unicode “REPLACEMENT CHARACTER”.

OK got it, goal without the --guess-format option is reading the public key bytes as an ascii string, replacing unknow characters with the the unicode “REPLACEMENT CHARACTER” (the infamous “?”).

You can recreate it with the following python code:

address = "FOPPYSPD3UANWENNYAIWFSLN4DLD4R2P4KVXKM5GWDQSGNU4FBEH2Y2K5M"

encoded_address = algosdk.encoding.decode_address(address)

# the “replace” option replaces any non-ascii characters with a unicode replacement character instead of throwing an error
goal_string = encoded_address.decode("ascii", "replace") .encode("unicode_escape")

print(goal_string.encode("utf-8"))