Javac -encoding options

5.7k views Asked by At

Where can I find a complete listing of all the character encodings supported by the javac command?

I have found suggestions of how to specify the encoding that a file uses with the -encoding flag in other answers, which contain several useful examples of supported encodings encountered commonly in the wild. I think it would also be useful if an exhaustive list was documented somewhere, and I have not found one.

Perhaps it depends on the version of javac? Perhaps also it coincides completely with the number of encodings that the java standard library has support for? I suppose the first step is to generate a list of encodings which are supported by the library, which has been done, but even if this is done it's not completely clear we'd be left with an exhaustive list.

2

There are 2 answers

1
hagrawal7777 On

Each J2SE version will list its supported encoding sets. For example, this show the encoding sets supported by Java SE 7

javac is the compiler, encoding sets doesn't depend upon compiler version but each release will list its supported encoding sets.

Hope this helps!

0
Jonathan Rosenne On

The link above gives the required minimum: "The java.io.InputStreamReader, java.io.OutputStreamWriter, java.lang.String classes, and classes in the java.nio.charset package can convert between Unicode and a number of other character encodings. The supported encodings vary between different implementations of the Java Platform, Standard Edition 7 (Java SE 7). The class description for java.nio.charset.Charset lists the encodings that any implementation of the Java Platform, Standard Edition 7 is required to support."

See availableCharsets which gives the collection of all character encodings actually supported by the implementation you happen to be using.