You are here

public static function ApacheSolrDocument::stripCtrlChars in Apache Solr Search 6.3

Same name and namespace in other branches
  1. 8 Apache_Solr_Document.php \ApacheSolrDocument::stripCtrlChars()
  2. 7 Apache_Solr_Document.php \ApacheSolrDocument::stripCtrlChars()

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

Parameters

string $string:

Return value

string

1 call to ApacheSolrDocument::stripCtrlChars()
ApacheSolrDocument::documentToXml in ./Apache_Solr_Document.php
Create an XML fragment from a ApacheSolrDocument instance appropriate for use inside a Solr add call

File

./Apache_Solr_Document.php, line 402

Class

ApacheSolrDocument
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> ... $document->title = 'Something'; echo…

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);
}