Java String Sanitize sanitize(String s, boolean allowColorCodes)

Here you can find the source of sanitize(String s, boolean allowColorCodes)

Description

sanitize

License

Apache License

Declaration

public static String sanitize(String s, boolean allowColorCodes) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String sanitize(String s, boolean allowColorCodes) {
        // well-known client crash in FontRenderer
        while (s.endsWith("\u00a7"))
            s.substring(0, s.length() - 1);

        // strip minecraft and IRC codes
        if (!allowColorCodes)
            s = s.replace('\u00a7', ' ').replace((char) 0x03, ' ').replace((char) 0x02, ' ')
                    .replace((char) 0x1D, ' ').replace((char) 0x1F, ' ').replace((char) 0x16, ' ');

        // nope//from  w w  w. j a  v a  2  s  .c om
        s = s.replace('\n', ' ').replace('\r', ' ').replace('\b', ' ').replace('\f', ' ').replace("\t", "    ");

        return s;
    }
}

Related

  1. sanitize(String original)
  2. sanitize(String path)
  3. sanitize(String s)
  4. sanitize(String s)
  5. sanitize(String s)
  6. sanitize(String source)
  7. sanitize(String str)
  8. sanitize(String string)
  9. sanitize(String string, boolean allowWhitespace)