You are here

public function PoStreamReader::parseQuoted in Localization update 7.2

Parses a string in quotes.

Parameters

string $string: A string specified with enclosing quotes.

Return value

string|FALSE The string parsed from inside the quotes.

1 call to PoStreamReader::parseQuoted()
PoStreamReader::readLine in includes/gettext/PoStreamReader.php
Reads a line from the PO stream and stores data internally.

File

includes/gettext/PoStreamReader.php, line 559
Contains \Drupal\Component\Gettext\PoStreamReader.

Class

PoStreamReader
Implements Gettext PO stream reader.

Code

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