Internet Explorer wordwrap doesn’t break at commas

I was modifying my web based thumbnail image viewer. Under each thumb I wanted the description of the photo. I wanted the photos to have captions below, and the unit to be rendered horizontally so they will fill the IE width. However, Internet Explorer will not break a line to wordwrap text after a comma if there is no space after it “like,this”. I didn’t want to modify the text in the database and insert spaces. One solution would be to find all occurrences of comma followed by a non-space and replace with comma space plus the non-space character. A simpler way: I just added a line to the HTML generator:


      notes= STRTRAN(STRTRAN(notes,”,”,”, “),”  “,” “)      && so IE wordwraps


First it replaces all commas with comma space, then it replaces all double spaces with a single space. This is extra work if the comma already had a space after it, but it was easy to do and the amount of extra work is peanuts compared to the disk I/O to get the thumbnail image.


Comments (5)

  1. Name says:










  2. anon says:

    So you are going to replace commas in number thousand operators for instance. Cool, I can’t wait to see this.

  3. Calvin,

    In addition to the issue with thousand seperators, there’s also the issue of commas embedded in URL’s that may also be in your notes?

    Also, I’ve found that I need to put space compression in a loop if you think there will be more than 5 spaces in a row in your content, i.e.

    do while " " $ lcStr

    lcStr = strtran( lcStr, " ", " " )



  4. David Fung says:

    From the original post of replacing double spaces with single space, why bother to do so? I thought HTML will treat multiple spaces as one.

  5. Calvin_Hsia says:

    Since my photograph descriptions don’t have large numbers or URLs, the issues of commas as thousands separator or in URLs don’t matter to me. I wanted the descriptions to wordwrap and fit under the thumbnails, using DIV tags. IE will automatically wordwrap, but only at spaces.