# HTMLWindow limits?

**URL:** <https://www.ruby-forum.com/t/htmlwindow-limits/167825>\
**Category:** wxRuby\
**Created:** [May 13, 2009, 1:35am UTC](https://www.ruby-forum.com/t/htmlwindow-limits/167825 "2009-05-13T01:35:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vkd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/d9b06d/32.png) [@vkd](https://www.ruby-forum.com/u/vkd)\
**Post date:** [May 13, 2009, 1:35am UTC](https://www.ruby-forum.com/t/htmlwindow-limits/167825/1 "2009-05-13T01:35:40Z")

</div>

Hi,  
I’m trying to write a simple email client using wxruby, and using  
HTMLWindow to display the email contents. But HtmlWindow seems to have a  
limit of 2362 bytes on the size of the page it would load - which I  
found emperically by limiting the size of text i passed into the  
control. Is this a known problem, or am I setting things wrongly?

Here’s the relevant piece of code:

```
class ItemDetail < Panel
  def initialize(parent,items,log)
    super(parent)
    @items=items
    @log=log

    @sizer = Wx::BoxSizer.new(Wx::VERTICAL)
      add_from
    add_message
    set_sizer(@sizer)
  end
  def add_from
    @from=TextCtrl.new(self,-1,"",:name=>"fromtxtctrl")
    @sizer.add(@from,1,Wx::ALL|Wx::GROW)
  end

  def add_message
    @message=HtmlWindow.new(self,:name=>"msghtmlwindow")
    @sizer.add(@message,10,Wx::ALL|Wx::GROW)
  end

  def setItem(index)
    begin
      item=@items[index]
      @from.set_value(item.from)
      #@message.set_value(item.body[0..2362]) #emperically found that
this is the limit for page size.
    rescue Exception => err
      @log.write_text('invalid item index: "%d, or err:%s"'
%[index,err.message])
    end
  end
end
```

---

<div class="post-metadata">

**Author:** ![vkd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/d9b06d/32.png) [@vkd](https://www.ruby-forum.com/u/vkd)\
**Post date:** [May 13, 2009, 1:38am UTC](https://www.ruby-forum.com/t/htmlwindow-limits/167825/2 "2009-05-13T01:38:50Z")

</div>

Vk Dee wrote:  
Correction: the set\_value line is not commented out. It should read like  
so:

> ```
> @message.set_value(item.body[0..2362]) #emperically found that
> 
> ```

---

<div class="post-metadata">

**Author:** ![vkd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/d9b06d/32.png) [@vkd](https://www.ruby-forum.com/u/vkd)\
**Post date:** [May 14, 2009, 3:19pm UTC](https://www.ruby-forum.com/t/htmlwindow-limits/167825/3 "2009-05-14T15:19:52Z")

</div>

Vk Dee wrote:

> I’m trying to write a simple email client using wxruby, and using  
> HTMLWindow to display the email contents. But HtmlWindow seems to have a  
> limit of 2362 bytes on the size of the page it would load - which I  
> found emperically by limiting the size of text i passed into the  
> control. Is this a known problem, or am I setting things wrongly?

No, there is no such limit on the size of text to be displayed.

Does this problem arise with a particular text, or any HTML text? I  
would check whether the HTML string you are providing is correctly  
encoded in UTF-8 - if not, you might get this kind of truncation at an  
invalid byte.

> Here’s the relevant piece of code:

Thanks for posting code, but it’s not possible to check it out unless  
it’s self-contained and runnable. We can’t reconstruct and imagine what  
the rest of the program is doing. Often you will find the process of  
reducing it to a basic sample illustrating the problem will show up the  
root cause.

a

---

<div class="post-metadata">

**Author:** ![vkd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/d9b06d/32.png) [@vkd](https://www.ruby-forum.com/u/vkd)\
**Post date:** [May 14, 2009, 11:44pm UTC](https://www.ruby-forum.com/t/htmlwindow-limits/167825/4 "2009-05-14T23:44:58Z")

</div>

> No, there is no such limit on the size of text to be displayed.  
> ok
> 
> Thanks for posting code, but it’s not possible to check it out unless  
> it’s self-contained and runnable. We can’t reconstruct and imagine what  
> the rest of the program is doing. Often you will find the process of  
> reducing it to a basic sample illustrating the problem will show up the  
> root cause.

fair enough. i’ll try and put in a self-contained sample. and check out  
the possibility of rogue html.  
Thanks

---

<div class="post-metadata">

**Author:** ![vkd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/d9b06d/32.png) [@vkd](https://www.ruby-forum.com/u/vkd)\
**Post date:** [May 15, 2009, 12:13am UTC](https://www.ruby-forum.com/t/htmlwindow-limits/167825/5 "2009-05-15T00:13:09Z")

</div>

Also, keep in mind that HTMLWindow is not a full blown Browser Engine,  
like  
what you would get with the Mozilla Engine, or IE’s ActiveX Control, or  
even  
WebKit. HTMLWindow can only handle a small subset of HTML Tags, and is  
very  
strict in what it will properly interpret. So make sure your not using  
anything that’s above HTML 3.0 strict set. Or something along thoes  
lines.

---

<div class="post-metadata">

**Author:** ![vkd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/d9b06d/32.png) [@vkd](https://www.ruby-forum.com/u/vkd)\
**Post date:** [May 15, 2009, 2:21am UTC](https://www.ruby-forum.com/t/htmlwindow-limits/167825/6 "2009-05-15T02:21:26Z")

</div>

Update: it does look like a case of bad html.  
Thanks for the quick response. I’ll update this thread if there’s  
anything new to add.

> > 
> 
> fair enough. i’ll try and put in a self-contained sample. and check out  
> the possibility of rogue html.  
> Thanks

---

<div class="post-metadata">

**Author:** ![vkd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/d9b06d/32.png) [@vkd](https://www.ruby-forum.com/u/vkd)\
**Post date:** [May 15, 2009, 1:41pm UTC](https://www.ruby-forum.com/t/htmlwindow-limits/167825/7 "2009-05-15T13:41:15Z")

</div>

Vk Dee wrote:  
Final update:  
My fix in case anyone has the same problem was to replace all  
non-printable characters like so:  
htmlstring.gsub(/[\[1\]]/, ‘’)

> Update: it does look like a case of bad html.  
> Thanks for the quick response. I’ll update this thread if there’s  
> anything new to add.

* * *

1. :print:
