0

Since Mozilla's btoa and atob aren't compatible with IE, Im using Nick Galbreath's solution that works across the board.

In my JS, I have this snippet:

reader.onload = function (e)
{
    var base64str = e.target.result.split(';')[1].split(',')[1];
    var binaryData = base64.decode(base64str); 
    
    // binaryData looks like: 3!1AQa"q2¡±B#$RÁb34rÑC%Sðáñcs5¢²&DTdE£t
    // 6ÒUâeò³ÃÓuãóF'¤´ÄÔäô¥µÅÕåõVfv¦¶ÆÖæö7GWgw§·Ç×ç÷5!1AQaq"2¡±B#ÁRÑð
    // 3$bárCScs4ñ%¢²&5ÂÒDT£dEU6teâò³ÃÓuãóF¤´ÄÔäô¥µÅÕåõVfv¦¶ÆÖæö'7GWgw
    // §·ÇÿÚ?õTI%)$IJI$RIrÿ[múÙxÝ^«ÝKØrþk²ïÑûíGóß÷¿ÑþÄY«ÍÓ±×úN //...
    // Is this even binary data?

    Ajax.SendToHandler(binaryData);
}

How do I convert binaryData, which is sent to my ashx derived IHttpHandler as a string, into a bytes[] array?

Ask me to clarify where needed!

4

1 回答 1

2

您的数据字符串似乎只包含扩展的 ASCII 字符(可能是 Windows-1252 字符或 ISO 8859-1 字符)。您应该尝试使用 aSystem.Text.Encoding将其转换为字节。

于 2013-05-16T22:19:49.083 回答