Exemplo n.º 1
0
        public static void ReadBufferAndWriteTo(this JsBuffer jsBuffer, System.IO.MemoryStream ms)
        {
            //write to mem-stream
            int buff_len = jsBuffer.GetBufferLen();

            byte[] buff = new byte[buff_len];
            unsafe
            {
                fixed(byte *buff_ptr = &buff[0])
                {
                    jsBuffer.CopyBuffer((IntPtr)buff_ptr, buff_len);
                }
            }
        }
Exemplo n.º 2
0
        public static string ReadBufferAsString(this JsBuffer jsBuffer, System.Text.Encoding enc = null)
        {
            int buff_len = jsBuffer.GetBufferLen();

            byte[] buff = new byte[buff_len];
            unsafe
            {
                fixed(byte *buff_ptr = &buff[0])
                {
                    jsBuffer.CopyBuffer((IntPtr)buff_ptr, buff_len);
                }
            }

            if (enc == null)
            {
                enc = System.Text.Encoding.UTF8;
            }
            return(enc.GetString(buff));
        }