JDK-1267094 : writeUTF arbitrarily truncates Strings
  • Type: Enhancement
  • Component: other-libs
  • Sub-Component: other
  • Affected Version: 1.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.4
  • CPU: sparc
  • Submitted: 1996-09-09
  • Updated: 1997-02-06
  • Resolved: 1997-02-06
Related Reports
Duplicate :  
Relates :  
Description
writeUTF silently throws away characters in a String after it has used
up 2^16-1 bytes of encoding.  I have no way of knowing when that point
will be -- it depends on exactly what characters are in the string.
There is no excuse for silent truncation, or for any truncation at all.

Comments
SUGGESTED FIX When the length of a particular encoding excedes some chunk length (I suppose 2^16-1 is a good chunk length), follow that chunk by the next 2^16-1, and so on until there are no more characters to write. If a chunk is exactly 2^16-1, the length of the next chunk is 0. This should be a trivial rewrite of the read/write UTF methods into loops.
11-06-2004

PUBLIC COMMENTS writeUTF silently throws away characters in a String after it has used up 2^16-1 bytes of encoding. I have no way of knowing when that point will be -- it depends on exactly what characters are in the string. There is no excuse for silent truncation, or for any truncation at all.
10-06-2004