While writing an encryption method in JavaScript, I came to wondering what character encoding my strings were using, and why.
What determines character encoding in JavaScript? Is it a standard? By the browser? Determined by the header of the HTTP request? In the <META>
tag of HTML that encompasses it? The server that feeds the page?
By my empirical testing (changing different settings, then using charCodeAt
on a sufficiently strange character and seeing which encoding the value matches up with) it appears to always be UTF-8 or UTF-16, but I'm not sure why.
After some frantic googling, I couldn't seem to find a conclusive answer to this simple question.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…