Hello,

When using the Gears HttpRequest object and trying to call
hr.responseText with a response that contains accents and is encoded
in ISO-8859-1 (charset specified in the response http headers), I'm
getting an "Internal error" exception.
Whereas using HttpRequest.responseBlob doesn't cause any problem.

Wouldn't it be a bug with Gears ?


At the moment, I use the following function to bypass this problem :


function readResponse(httprequest) {
        try {
                return httprequest.responseText;
        } catch (e) {
                var blob = httprequest.responseBlob.getBytes();
                /* 
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String/fromCharCode
*/
                for (var b=0,l=blob.length ; b<l ; b++) {
                        if (blob[b] > 0xFFFF) {
                                blob[b] -= 0x10000;
                                blob[b] = String.fromCharCode(0xD800 + (blob[b] 
>> 10), 0xDC00 +
(blob[b] & 0x3FF));
                }
                else {
                        blob[b] = String.fromCharCode(blob[b]);
                }
                }
                return blob.join('');
        }
}

Reply via email to