2 Replies Latest reply on Mar 3, 2005 5:14 AM by Gergely Bereczki

    Problem adding html content with swedish characters

    Fredrik Fall Newbie


      I edit an html page using the 'manage html' screen, and I type in some swedish characters such as å.ä or ö (hopefully these will be displayed correctly here) and submit the page. When I display the page again, the content is cut short directly after the last occurence of a swedish character.
      If the last sentence is "Hjärtligt välkomna" , then the output is just "Hjärtligt vä".
      I'm using nukes-1.1.0-rc3 built from source and using mysql, running on jboss-3.2.3, and I'm using keymap iso-8859-1. If I peek inside pn_content of the nuke_file table of the db, the html content looks almost alright

      "Hjärtligt välkomma"

      I expect that the swedish chars are stored in unicode which my xterm currently is unable show. At least the entire string is stored in the db.

      So, has anyone run into a similar problem with their international characters?
      If I type the html code for the characters (&auml and such) it works fine, but this is not ok for non-html-nerds to type.

        • 1. Re: Problem adding html content with swedish characters
          Thomas Heute Master

          I am pretty this has been solved in the CVS, i just can't find which file was involved right now.

          Messages related to your problem has been posted on this forum (I can't find them though)

          • 2. Re: Problem adding html content with swedish characters
            Gergely Bereczki Newbie


            I didnt check CVS for this bugfix, but the bug is in the org.jboss.nukes.common.util.EntityTable class, in the

            public final String convertEntities(String txt)

            The problem is, when it replaces extra characters, it checks if there is more characters to replace, and if not, then it finishes to process the string.

            I fixed it this way:

             public final String convertEntities(String txt)
             StringBuffer result = null;
             char[] chars = txt.toCharArray();
             int previous = 0;
             for (int current = 0;current < chars.length;current++)
             String replacement = lookup(chars[current]);
             // Do we have a replacement
             if (replacement != null)
             // We lazy create the result
             if (result == null)
             // Allocate 1/2 more than the current txt size
             result = new StringBuffer(txt.length() * 3 / 2);
             // Append the previous chars if any
             result.append(chars, previous, current - previous);
             // Append the replaced entity
             // Update the previous pointer
             previous = current + 1;
             } else {
             // finish string
             if (current == chars.length-1) {
             result.append(chars, previous, current - previous + 1);
             return result != null ? result.toString() : txt;

            Then just compile the source and it works fine. I hope I could help.