Exemplo n.º 1
0
        protected void WriteUTF8ResourceString(HtmlTextWriter output, int offset, int size, bool fAsciiOnly)
        {
            if (resource_data == null)
            {
                return;                 // throw?
            }
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (offset > resource_data.MaxOffset - size)
            {
                throw new ArgumentOutOfRangeException("size");
            }

            //TODO: fAsciiOnly?
            IntPtr     ptr    = AddOffset(resource_data.Ptr, offset);
            HttpWriter writer = output.GetHttpWriter();

            if (writer == null || writer.Response.ContentEncoding.CodePage != 65001)
            {
                byte [] bytes = new byte [size];
                Marshal.Copy(ptr, bytes, 0, size);
                output.Write(Encoding.UTF8.GetString(bytes));
                bytes = null;
                return;
            }

            writer.WriteUTF8Ptr(ptr, size);
        }
Exemplo n.º 2
0
        override void Render(HtmlTextWriter writer)
        {
            if (length == -1)
            {
                writer.Write(base.Text);
                return;
            }

            HttpWriter hw = writer.GetHttpWriter();

            if (hw == null || hw.Response.ContentEncoding.CodePage != 65001)
            {
                byte [] bytes = new byte [length];
                Marshal.Copy(ptr, bytes, 0, length);
                writer.Write(Encoding.UTF8.GetString(bytes));
                bytes = null;
                return;
            }

            hw.WriteUTF8Ptr(ptr, length);
        }