Q:

Read non printable characters from Javascript

Say I have the following Javascript instruction:

var a="hiàja, c . Non di–g t";

a contains binary data, i.e., any ASCII from 0-255.
Before what ASCII bytes should I add backslash so that a is read properly? (for example, before "). 
Should I use an specific charset and content-type different than text/Javascript and UTF-8?
Thanks

A:

The ASCII range is 0 to 127, but strings are not limited to ASCII in JavaScript. According to the ECMAScript standard, “All characters may appear literally in a string literal except for the closing quote character, backslash, carriage return, line separator, paragraph separator, and line feed.” If the encoding of your document is suitable (e.g., windows-1252 or utf-8) and properly declared, you can use your example string as it is.

