whitespaceEscape static method

String whitespaceEscape(
  1. String str
)

Do escaping of whitespace to preserve spatial formatting. We use character entity #160 to make it safer for xml. @param {string} str The string in which to escape whitespace. @param {bool=} opt_xml Whether to use XML compatible tags. @return {string} An escaped copy of {@code str}.

Implementation

static String whitespaceEscape(String str)
{
  // This doesn't use goog.string.preserveSpaces for backwards compatibility.
  return newLineToBr( str.replaceAll(_WHITESPACE_RE, "  ") );
}