commandBuilder.append(parameter);
}
- logger.trace(String.format(">> %s", commandBuilder));
+ logger.trace(String.format(">> %s", addEscapeCharacters(commandBuilder)));
outputStream.write((commandBuilder.toString() + "\r\n").getBytes("UTF-8"));
outputStream.flush();
}
+ private String addEscapeCharacters(StringBuilder commandBuilder) {
+ StringBuilder escaped = new StringBuilder();
+ for (char c : commandBuilder.toString().toCharArray()) {
+ if (c < 32) {
+ escaped.append("\\CTRL[").append((int) c).append("]");
+ } else {
+ escaped.append(c);
+ }
+ }
+ return escaped.toString();
+ }
+
/**
* Reads a line of reply from the connection.
*