function PoStreamReader::parseQuoted

PoStreamReader::parseQuoted($string)

Parses a string in quotes.

Parameters

$string: A string specified with enclosing quotes.

Return value

The string parsed from inside the quotes.

File

core/lib/Drupal/Component/Gettext/PoStreamReader.php, line 550

Class

PoStreamReader
Implements Gettext PO stream reader.

Namespace

Drupal\Component\Gettext

Code

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Gettext!PoStreamReader.php/function/PoStreamReader::parseQuoted/8.1.x