forked from phoedos/pmd
Bug fix and enhanced console output encoding
- due to some rewriting without testing, the encoding property was not added to the renderer properties. - better console encoding: use system property `sun.stdout.encoding` in interactive console, and `file.encoding` in piped or redirected output
This commit is contained in:
pyxide
committed by
Juan Martín Sotuyo Dodero
parent
4c71b0da4a
commit
abf65acb63
@ -70,9 +70,29 @@ public class Formatter {
|
||||
{
|
||||
String s = (String) properties.get("encoding");
|
||||
if (null == s) {
|
||||
charset = StandardCharsets.UTF_8;
|
||||
properties.put("encoding", charset.name());
|
||||
} else {
|
||||
|
||||
if (toConsole) {
|
||||
if(null == System.console()) {
|
||||
// pipe or redirect, no interactive console.
|
||||
s = System.getProperty("file.encoding");
|
||||
} else {
|
||||
s = System.getProperty("sun.stdout.encoding");
|
||||
}
|
||||
}
|
||||
|
||||
if (null == s) {
|
||||
charset = StandardCharsets.UTF_8;
|
||||
} else {
|
||||
charset = Charset.forName(s);
|
||||
}
|
||||
|
||||
// Configures the encoding for the renderer.
|
||||
final Parameter parameter = new Parameter();
|
||||
parameter.setName("encoding");
|
||||
parameter.setValue(charset.name());
|
||||
parameters.add(parameter);
|
||||
}
|
||||
else {
|
||||
charset = Charset.forName(s);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user