- java.lang.Object
-
- net.morimekta.strings.EscapeUtil
-
public final class EscapeUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
javaEscape(char c)
Escape a single character.static String
javaEscape(CharSequence string)
Properly java-escape the string for including in java strings or printing with escape symbols to console.static String
javaUnEscape(CharSequence str)
UnEscape the char sequence using javas escape syntax used above and in java strings.static String
javaUnEscape(CharSequence str, boolean strict)
UnEscape the char sequence using javas escape syntax used above and in java strings.
-
-
-
Method Detail
-
javaEscape
public static String javaEscape(CharSequence string)
Properly java-escape the string for including in java strings or printing with escape symbols to console.- Parameters:
string
- The string to escape.- Returns:
- The escaped string.
-
javaEscape
public static String javaEscape(char c)
Escape a single character. It is escaped into a string, as it may become more than one char when escaped. The char is escaped in a way that can be included in a java char- Parameters:
c
- The char to escape.- Returns:
- The escaped char string.
-
javaUnEscape
public static String javaUnEscape(CharSequence str)
UnEscape the char sequence using javas escape syntax used above and in java strings.- Parameters:
str
- The string to un-escape.- Returns:
- The un-escaped string.
-
javaUnEscape
public static String javaUnEscape(CharSequence str, boolean strict)
UnEscape the char sequence using javas escape syntax used above and in java strings.- Parameters:
str
- The string to un-escape.strict
- If it should validate string content strictly.- Returns:
- Slice decoded as UTF_8 string handling escaped characters.
-
-