MCPcopy Create free account
hub / github.com/PCGen/pcgen / escape

Method escape

PCGen-base/code/src/java/pcgen/base/util/CSVUtilities.java:41–52  ·  view source on GitHub ↗

Escapes a given entry. This escapes quotes (and detects commas that would require the line to be escaped). @param string The string to be escaped into its encoded state @return The escaped entry (with CSV quoting)

(String string)

Source from the content-addressed store, hash-verified

39 * @return The escaped entry (with CSV quoting)
40 */
41 public static String escape(String string)
42 {
43 if (string.contains("\"") || string.contains(","))
44 {
45 StringBuilder escaped = new StringBuilder(string.length() + 20);
46 escaped.append('"');
47 escaped.append(string.replace("\"", "\"\""));
48 escaped.append('"');
49 return escaped.toString();
50 }
51 return string;
52 }
53
54 /**
55 * Unescapes a given entry. This performs whitespace padding removal both

Callers

nothing calls this directly

Calls 4

containsMethod · 0.65
toStringMethod · 0.65
appendMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected