Class RemoveNonPrintableSanitizer

java.lang.Object
io.github.rabinarayanpatra.sanitizer.builtin.RemoveNonPrintableSanitizer
All Implemented Interfaces:
FieldSanitizer<String>

public class RemoveNonPrintableSanitizer extends Object implements FieldSanitizer<String>
Sanitizer that removes non-printable control characters from the input string.

This sanitizer removes all characters in the Unicode "Control" category (Cc, Cf, Cs, Co, Cn), except for the common whitespace characters: Tab (\t), Line Feed (\n), and Carriage Return (\r).

Example:

 
 String input = "HelloWorld";
 String sanitized = new RemoveNonPrintableSanitizer().sanitize(input); // "HelloWorld"
 
 
Since:
1.0.0
See Also:
  • Constructor Details

    • RemoveNonPrintableSanitizer

      public RemoveNonPrintableSanitizer()
      Default constructor.
  • Method Details

    • sanitize

      public @Nullable String sanitize(@Nullable String input)
      Removes non-printable characters from the input string.
      Specified by:
      sanitize in interface FieldSanitizer<String>
      Parameters:
      input - the string to sanitize
      Returns:
      the sanitized string, or null if input is null