function PoStreamReader::parseQuoted
Same name in other branches
- 9 core/lib/Drupal/Component/Gettext/PoStreamReader.php \Drupal\Component\Gettext\PoStreamReader::parseQuoted()
- 8.9.x core/lib/Drupal/Component/Gettext/PoStreamReader.php \Drupal\Component\Gettext\PoStreamReader::parseQuoted()
- 11.x core/lib/Drupal/Component/Gettext/PoStreamReader.php \Drupal\Component\Gettext\PoStreamReader::parseQuoted()
Parses a string in quotes.
Parameters
$string: A string specified with enclosing quotes.
Return value
bool|string The string parsed from inside the quotes. False when the syntax is invalid.
1 call to PoStreamReader::parseQuoted()
- PoStreamReader::readLine in core/
lib/ Drupal/ Component/ Gettext/ PoStreamReader.php - Reads a line from the PO stream and stores data internally.
File
-
core/
lib/ Drupal/ Component/ Gettext/ PoStreamReader.php, line 551
Class
- PoStreamReader
- Implements Gettext PO stream reader.
Namespace
Drupal\Component\GettextCode
public function parseQuoted($string) {
if (substr($string, 0, 1) != substr($string, -1, 1)) {
// Start and end quotes must be the same.
return FALSE;
}
$quote = substr($string, 0, 1);
$string = substr($string, 1, -1);
if ($quote == '"') {
// Double quotes: strip slashes.
return stripcslashes($string);
}
elseif ($quote == "'") {
// Simple quote: return as-is.
return $string;
}
else {
// Unrecognized quote.
return FALSE;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.