Yes that's helpful.
Unfortunately I'm not able to find a good solution right now... I'm trying to figure out the rules that the reference implementation is using to escape/unescape things.
The reference implementation produces: \xb3eª\xd0^\xbd\xdc<\x11\xef\x99
, which in JS-land represents this string: ³eªÐ^½Ü<\u0011ï
Unfortunately when I send that same XDR into the stellar js sdk, I get different values for the memo:
> new Transaction('AAAAAFVfweSWPl13mbB9OImqYMldc/S3X3V64/sNuDGTGDyBAAAAZAANP9YAAAABAAAAAAAAAAEAAAAMs2XCqtBe
vdw8Ee+ZAAAAAQAAAAAAAAAKAAAABWhlbGxvAAAAAAAAAQAAAAdwc2VsZGVuAAAAAAAAAAABkxg8gQAAAEAPdK3vJ713Q8MJHEZ8eTMH+fe
0a+bH1uXElSvFJY0OK/w1J9HIkmXk4l9W30B4/jfmMGox0jfqTWwhncVdEQIN').memo.value.toString('ascii')
'3eB*P^=\\<\u0011o\u0019'
> Memo.text('\xb3eª\xd0^\xbd\xdc<\x11\xef\x99').value.toString('ascii')
'³eªÐ^½Ü<\u0011ï'
I'm not sure how to proceed from there.
I have this code to do the unescape -- but I'm not actually sure how I'd go the reverse direction... maybe look at the charCodeAt for each character and if it's outside of some range, do the hex encoding (I'm not sure what that range is supposed to be though).
function unescapeHexCodes(line: string): string {
return line.replace(/\\x([0-9A-Fa-f]{2})/g, (_, match) => {
return String.fromCharCode(parseInt(match, 16));
});
}
So for right now I'm stuck. Unless anyone else has any ideas.