MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / fixString

Method fixString

ij/src/main/java/ij/plugin/frame/Recorder.java:222–241  ·  view source on GitHub ↗

Replaces special characters in a String for creation of a quoted macro String. Does not add quotes.

(String str)

Source from the content-addressed store, hash-verified

220
221 /** Replaces special characters in a String for creation of a quoted macro String. Does not add quotes. */
222 public static String fixString (String str) {
223 StringBuilder sb = new StringBuilder();
224 char c;
225 for (int i=0; i<str.length(); i++) {
226 c = str.charAt(i);
227 if (c =='\\' || c=='"')
228 sb.append("\\"+c);
229 else if (c == '\n')
230 sb.append("\\n");
231 else if (c < ' ' || c > '~' && c < 0xa0) {
232 sb.append('\\');
233 String octal = Integer.toString(c,8);
234 while (octal.length()<3)
235 octal = '0' + octal;
236 sb.append(octal);
237 } else
238 sb.append(c);
239 }
240 return new String(sb);
241 }
242
243 public static void record(String method, String arg) {
244 if (IJ.debugMode) IJ.log("record: "+method+" "+arg);

Callers 4

recordOptionMethod · 0.95
recordMethod · 0.95
getNextStringMethod · 0.95
getNextTextMethod · 0.95

Calls 4

charAtMethod · 0.80
lengthMethod · 0.65
appendMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected