Render asset codes in JSON as UTF-8 strings, where any bytes are not printable ASCII are escaped using the rules defined by https://docs.rs/escape-bytes.
Why
Valid asset codes are some subset of ASCII, but they're currently rendered as hex. It creates a poor and difficult experience when a developer is expecting to see their asset code in the JSON and instead see hex.
The codes are rendered to a subset of UTF-8 because JSON strings must be Unicode.
XDR defines its strings to be ASCII, but can otherwise hold any byte sequences, even invalid ASCII.
Because the data can be any byte sequence, escaping any non-printable ASCII characters means that the majority of valid and meaningful data will be human readable, while all data is still roundtrippable.
Another option would have been to only escape invalid UTF-8 byte sequences, however reproducing that behavior exactly the same in a variety of SDKs would be more challenging.
What
Render asset codes in JSON as UTF-8 strings, where any bytes are not printable ASCII are escaped using the rules defined by https://docs.rs/escape-bytes.
Why
Valid asset codes are some subset of ASCII, but they're currently rendered as hex. It creates a poor and difficult experience when a developer is expecting to see their asset code in the JSON and instead see hex.
The codes are rendered to a subset of UTF-8 because JSON strings must be Unicode.
XDR defines its strings to be ASCII, but can otherwise hold any byte sequences, even invalid ASCII.
Because the data can be any byte sequence, escaping any non-printable ASCII characters means that the majority of valid and meaningful data will be human readable, while all data is still roundtrippable.
Another option would have been to only escape invalid UTF-8 byte sequences, however reproducing that behavior exactly the same in a variety of SDKs would be more challenging.
Discussion at https://discord.com/channels/897514728459468821/1179194134783868988
Close stellar/xdrgen#175
Follow ups