can javascript process binary data?

Posted by Johnny on Stack Overflow See other posts from Stack Overflow or by Johnny
Published on 2010-05-12T09:42:57Z Indexed on 2010/05/15 14:34 UTC
Read the original article Hit count: 270

admit me describe my questions in situation-oriented way:

assume IE is still the dominate web browser(the firefox have document for binary processing):

the XMLHttpRequest.responseText or XMLHttpRequest.responseXML in ie desire txt or xml/xhtml/html,but what about the server response the xmlHttprequest whith MIME TYPE application/octet ? would the response string all little than 256 ?(every char of that string < 256), thanks very much for a straight answer, i have no webserver env,so i don't know how to test it out.

because use txt or xml have a issue of character set encode, and i don't know how to process #[[[CDDATA node of one encoded xml(ex : utf-8,ascii,gb18030) with javascript, when i getNodeText, does the docObj return me byte or decoded char ? if it was decoded char which according to the header indicated charSet in the httpresponse , it would be all wrong.

to avoid mess up with charSet ,i would like the server to response octet data and force strings data to be encoded as utf-8 but another charSet in the binary format.

if the response is octal, so i guess the browser would not try to decode the response"txt"

does this weird? or miss understanding the fundamental things?

EDIT: I believe the question is asking this: Can Javascript safely process strings that aren't encoded in Unicode? What are the problems with trying to do so?

EDIT: no no no , i means if http-header: content-type is "application/octet" , would the ie try to decoded it as (16bits Unicode | ie local setting charset ) when i get XMLHttpRequestobj.responseText use javascript ? or it(ie) just wrap every single byte of the response body as a javascript string, then every char in that string little than or equal 256 (char<=256),

am i talking Mars language? sadly, if i were Marsizen,i would come as tourist without fuzzy questions. however i am in a country which share at least one property with Mars : RED

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about xmlhttprequest