[e-lang] Unicode annoyance (was: Notes from latest Joe-E meeting)

Mark S. Miller markm at cs.jhu.edu
Sat Apr 28 15:33:34 EDT 2007


In java.io.Writer.taming, I changed

     write(char)

to

     write(int)

This reflects the mysterious fact that java.io.Writer does not define a 
write(char) method, but does define a write(int) method that acts exactly as 
one should expect a write(char) method to act. In particular, 
Writer#write(int) only pays attention to the low order 16 bits of the 
argument, effectively treating it as a UTF-16 code point, i.e., as a Java char.

This is inconsistent with other places in the Java 1.5 API, such as
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#indexOf(int)>,
where the use of an "int" as a character type indicates that a Unicode 
character code is expected and all 21 bits of significance are significant.

-- 
Text by me above is hereby placed in the public domain

     Cheers,
     --MarkM


More information about the e-lang mailing list