Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4018571

(spec) java.io.DataOutput.writeUTF method documentation is wrong

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      kestrel
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description

      JLSv1.0 says (22.2.14):

      "If a character c is in the range '\u0800' through '\uffff', then it is
       represented by three bytes, to be written in the order shown:
          (byte)(0xc0 | (0x0f & (c >> 12)))
                ^^^^^^ Should be 0xE0 !!!!!
          (byte)(0x80 | (0x3f & (c >> 6)))
          (byte)(0x80 | (0x3f & c))"

      Here is the part of the source code for java.ioRandomAccessFile.writeUTF():
      for (int i = 0 ; i < strlen ; i++) {
      int c = str.charAt(i);
      if ((c >= 0x0001) && (c <= 0x007F)) {
      write(c);
      } else if (c > 0x07FF) {
      write(0xE0 | ((c >> 12) & 0x0F));
                          ^^^^^^^^
      write(0x80 | ((c >> 6) & 0x3F));
      write(0x80 | ((c >> 0) & 0x3F));
      //written += 2;
      } else {
      write(0xC0 | ((c >> 6) & 0x1F));
      write(0x80 | ((c >> 0) & 0x3F));
      //written += 1;
      }
      }

        Attachments

          Activity

            People

            Assignee:
            mmcclosksunw Michael Mccloskey (Inactive)
            Reporter:
            mgorshen Mikhail Gorshenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: