+ /**
+ * Sanitise the given input to make it more Terminal-friendly by removing
+ * combining characters.
+ *
+ * @param input
+ * the input to sanitise
+ * @param allowUnicode
+ * allow Unicode or only allow ASCII Latin characters
+ *
+ * @return the sanitised {@link String}
+ */
+ static public String sanitize(String input, boolean allowUnicode) {
+ return sanitize(input, allowUnicode, !allowUnicode);
+ }
+
+ /**
+ * Sanitise the given input to make it more Terminal-friendly by removing
+ * combining characters.
+ *
+ * @param input
+ * the input to sanitise
+ * @param allowUnicode
+ * allow Unicode or only allow ASCII Latin characters
+ * @param removeAllAccents
+ * TRUE to replace all accentuated characters by their non
+ * accentuated counter-parts
+ *
+ * @return the sanitised {@link String}
+ */
+ static public String sanitize(String input, boolean allowUnicode,
+ boolean removeAllAccents) {
+
+ if (removeAllAccents) {
+ input = Normalizer.normalize(input, Form.NFKD);
+ input = marks.matcher(input).replaceAll("");
+ }
+
+ input = Normalizer.normalize(input, Form.NFKC);
+
+ if (!allowUnicode) {
+ input = notAscii.matcher(input).replaceAll("");
+ }
+
+ return input;
+ }