Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-895

Shell crops Strings with UTF-8 charaters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • 1.3.0.Final
    • 1.2.3.Final
    • UI - Shell
    • None

    Description

      when I try to print some UTF-8 characters in the shell the end of the line is cropped. E.g.

      shell.print("\u2501 Hello World"); 
      

      results in

      ━ Hello Wor
      

      Looks like the org.jboss.forge.shell.buffers.JLineScreenBuffer is calculating the BufferSize wrong:

      public synchronized void write(String s) {
            if (bufferSize + s.length() >= maxBufferSize)
            {
               flushBuffer();
               write(s);
            }
      
            buffer.put(s.getBytes());
            bufferSize += s.length();
            _flush();
      }
      

      s.length() is returning the size of the used Characters, not the Size of the used Bytes. Could be replaced by s.getBytes("UTF-8").length or e.g. this calculation method

      Attachments

        Activity

          People

            rhn-support-ggastald George Gastaldi
            lefloh Florian Hirsch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: