This content has been marked as final. Show 3 replies
Strings are null-terminated. You can prove this by changing the 'B2' character to null (00) and your returned string will only be '\xF4\t'. It follows the C-String standard.
I have written my own Base64 encoding but have not yet worked out if the time taken is worth saving the 33% of the transmission size.
If anyone is interested;
var base64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split("");
var result = "";
var padding = "";
for (i = (hexString.length * 2) % 3; i > 0 && i < 3; i++)
padding += '=';
hexString += "00";
for (i = 0; i < hexString.length; i += 6)
var n = (parseInt(hexString.substring(i, i+2), 16) << 16) + (parseInt(hexString.substring(i+2, i+4), 16) << 8 ) + (parseInt(hexString.substring(i+4, i+6), 16));
result += base64chars[(n >>> 18) & 63] + base64chars[(n >>> 12) & 63] + base64chars[(n >>> 6) & 63] + base64chars[n & 63];
return result.substring(0, result.length - padding.length) + padding;
This takes the hex string that you would get from a call to SOAP.streamEncode, e.g.
var string2 = new String("\xF4\x09\xB2\x0q\x00\x00\x00\x00");
var string3 = string2;
string2 will have the nulls, string3 will not.