As per the ECMA-262 5th Edition:
A conforming implementation of this International standard shall interpret characters in conformance with the Unicode Standard, Version 3.0 or later and ISO/IEC 1064 6-1 with either UCS-2 or UTF-16 as the adopted encoding form, implementation level 3. If the adopted ISO/IEC 10646-1 subset is not otherwise specified, it is presumed to be the BMP subset, collection 300. If the adopted encoding form is not otherwise specified, it presumed to be the UTF-16 encoding form.
This brings me to the following questions:
- The UTF-16 or UCS-2 recommended by ECMAScript standard refers to the encoding form to be used for storage purposes or computation purposes?
- What character encoding (for storage purposes) is used to store cookies on the client?
- Also, since HTTP header values don't allow non US-ASCII characters, does the browser change the character encoding to ASCII before sending cookies to a server?
I'm particularly interested in the character encoding browsers use for storing cookies since that would let me calculate the actual number of bytes I could use per cookie.