In env-js/src/platform/rhino @ line 251
xhr.responseText = java.nio.charset.Charset.forName("UTF-8").
decode(java.nio.ByteBuffer.wrap(baos.toByteArray())).toString()+"";
will either explode with an exception or produce junk if the
doco is in latin-1 (or equiv)
First step is to write a test to prove this. then ideally follow
a basic charset sniffer algorithm:
- use content-type;charset=
- if html, look for meta tag
- look at byte-order marks
- default to utf8
there are more complicated versions to do this, but this should
cover the basics
In a different note, a bit above (line 219)
var contentEncoding = connection.getContentEncoding() || "utf-8",
should just be || '', the content-encoding isn't used for
charset encoding.