Hello!
I use...
DelphiDataSetToRtc(myDataSet, lRtcDataSet);
Server.Write(lRtcDataSet.toJSON);
...a very nice setup.
Then at the web browser (the client in this case) i access the /dsfields and if i find the type "WM" i use javascripts atob function to decode from base64. I can then use the strings in the page, for example by assigning object.innerHtml. This works like a charm.
The problem is when i need to produce a tag in my JS code. Like so:
innerHTML = '<a href="#" whatever="' + decodedMemoStringAsAbove + '">' + decodedMemoStringAsAbove + '</a>';
when i inspect the resulting element in the browser the string inside "" after whatever has charcode zero at every other character (the link text itself displays properly).
If myDataset's field property IsBlob is false i get a sting that can be used in both ways.
I know that the DelphiDataSetToRtc is just an example and i could change that to only use base64 (NewByteStream) for fields that are truly binary. However, this would entail digging into the implementation of toJSON too and i rather do not.
Q: So what have i done wrong? The page is utf-8 and i'm using Delphi XE2 on the backend side. I suspect this could be something internal to the browser but i'd like to understand why this happens before i write a JS snippet to remove the zeroes which would be unorthodox i think. Furthermore the servers functions (returning JSON) could be used as an API in the future and in that case any "special" stuff should be rooted out.
Thank you so much in advance,
/Dany
I can also add that i've been googling frantically and only found one other post indicating a similar problem but without any good answers.