dev@jsr311.java.net

Charset defaults

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Fri, 22 Feb 2008 11:23:11 -0500

Consider the following:

@GET
@ProduceMime("text/plain")
String get() {
   ...
}

What charset should we use to serialize the return value ?

We could assume that the developer intends the charset to be the
default ISO-8859-1 as specified in:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1

In which case we'd emit the content type as-is and just make sure to
use ISO-8859-1 for serialization.

Alternatively we could assume that the developer doesn't care what
charset is used and pick one for them like UTF-8. In that case we'd
add an explicit charset parameter to the media-type specified in
@ProduceMime (or via the Response).

A related question is what to do about other media types like
application/* where there is no common default. Should we always use
UTF-8 in that case unless there's an explicit charset parameter
specified ?

Marc.

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.