Reputation: 2493
According to this site, ASCII extended character codes 176, 177 and 178 correspond to three characters consisting in different shades of rectangles:
Here in more detail, character 178:
Now, according to https://mathiasbynens.be/notes/javascript-escapes, I should be able to escape any ASCII character with a code below 256 with, for example, its hex escape sequence. So, 176 would be \xB0
in hex. But instead of getting the expected character as described above, I get "degree symbol" '°'
. Degree symbol is ASCII 248, not 176, so.... what am I doing wrong?
Upvotes: 1
Views: 6527
Reputation: 943569
JavaScript deals in Unicode, not Extended ASCII.
Block elements hold positions 2580 to 259F
console.log("\u2592");
Upvotes: 2
Reputation: 42304
JavaScript uses Unicode, rather than extended ASCII. You can find the Unicode equivalent of the ASCII symbols by using String.prototype.charCodeAt(), and then output them with String.prototype.fromCharCode():
console.log("░".charCodeAt(0)); // 9617
console.log("▒".charCodeAt(0)); // 9618
console.log("▓".charCodeAt(0)); // 9619
console.log(String.fromCharCode(9617)); // ░
console.log(String.fromCharCode(9618)); // ▒
console.log(String.fromCharCode(9619)); // ▓
Hope this helps! :)
Upvotes: 4