protected function EasyRdf_Serialiser_GraphViz::escape

Internal function to escape a string into DOT safe syntax

@ignore

3 calls to EasyRdf_Serialiser_GraphViz::escape()

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/GraphViz.php, line 203

Class

EasyRdf_Serialiser_GraphViz
Class to serialise an EasyRdf_Graph to GraphViz

Code

protected function escape($input) {
  if (preg_match('/^([a-z_][a-z_0-9]*|-?(\\.[0-9]+|[0-9]+(\\.[0-9]*)?))$/i', $input)) {
    return $input;
  }
  else {
    return '"' . str_replace(array(
      "\r\n",
      "\n",
      "\r",
      '"',
    ), array(
      '\\n',
      '\\n',
      '\\n',
      '\\"',
    ), $input) . '"';
  }
}