开发者

how do I add an arbitrary byte value onto the end of a string? (JavaScript)

in JavaScript, how do I add an arbitrary byte value onto the end of a string? I'm trying开发者_JS百科 to construct an array which contains both ASCII and binary data, for passing to a remote server. I tried String.fromCharCode() but that only seems to work for bytes from 0x00 to 0x7f inclusive - larger byte values get turned into two-byte characters (which all makes sense now that I think about it).

Thanks in advance -


var myString = "Hello world";
myString += "\x21";
alert(myString);

Or, for a less canonical string that nonetheless demonstrates the range:

var myString = "Hello world";
myString += "\xE9";
alert(myString);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜