开发者

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

开发者 https://www.devze.com 2023-03-03 03:59 出处:网络
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

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

精彩评论

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