You are here

public static function SearchApiSolrDocument::stripCtrlChars in Search API Solr 7

Sanitizes XML for sending to Solr.

Replaces control (non-printable) characters that are invalid to Solr's XML parser with a space.

Parameters

string $string: The string to sanitize.

Return value

string A string safe for including in a Solr request.

1 call to SearchApiSolrDocument::stripCtrlChars()
SearchApiSolrDocument::toXml in includes/document.inc
Create an XML fragment from this document.

File

includes/document.inc, line 515

Class

SearchApiSolrDocument
Holds Key / Value pairs that represent a Solr Document along with any associated boost values. Field values can be accessed by direct dereferencing such as:

Code

public static function stripCtrlChars($string) {

  // See:  http://w3.org/International/questions/qa-forms-utf-8.html
  // Printable utf-8 does not include any of these chars below x7F
  return preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $string);
}