/[classpath]/classpath/java/io/DataOutputStream.java
ViewVC logotype

Diff of /classpath/java/io/DataOutputStream.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by mkoch, Wed Feb 16 11:18:37 2005 UTC revision 1.19 by dog, Thu Apr 14 21:33:28 2005 UTC
# Line 423  public class DataOutputStream extends Fi Line 423  public class DataOutputStream extends Fi
423      if (sum > 65535)      if (sum > 65535)
424        throw new UTFDataFormatException ();        throw new UTFDataFormatException ();
425    
426      writeShort (sum);      int pos = 0;
427        byte[] buf = new byte[sum];
428    
429      for (int i = 0; i < len; ++i)      for (int i = 0; i < len; ++i)
430        {        {
431          char c = value.charAt(i);          char c = value.charAt(i);
432          if (c >= '\u0001' && c <= '\u007f')          if (c >= '\u0001' && c <= '\u007f')
433            write (c);            buf[pos++] = (byte) c;
434          else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))          else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
435            {            {
436              write (0xc0 | (0x1f & (c >> 6)));              buf[pos++] = (byte) (0xc0 | (0x1f & (c >> 6)));
437              write (0x80 | (0x3f & c));              buf[pos++] = (byte) (0x80 | (0x3f & c));
438            }            }
439          else          else
440            {            {
441              // JSL says the first byte should be or'd with 0xc0, but              // JSL says the first byte should be or'd with 0xc0, but
442              // that is a typo.  Unicode says 0xe0, and that is what is              // that is a typo.  Unicode says 0xe0, and that is what is
443              // consistent with DataInputStream.              // consistent with DataInputStream.
444              write (0xe0 | (0x0f & (c >> 12)));              buf[pos++] = (byte) (0xe0 | (0x0f & (c >> 12)));
445              write (0x80 | (0x3f & (c >> 6)));              buf[pos++] = (byte) (0x80 | (0x3f & (c >> 6)));
446              write (0x80 | (0x3f & c));              buf[pos++] = (byte) (0x80 | (0x3f & c));
447            }            }
448        }        }
449        
450        writeShort (sum);
451        write(buf, 0, sum);
452    }    }
453    
454  } // class DataOutputStream  } // class DataOutputStream

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26