public static function EasyRdf_Serialiser_Turtle::quotedString in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Turtle.php \EasyRdf_Serialiser_Turtle::quotedString()
Given a string, enclose in quotes and escape any quotes in the string. Strings containing tabs, linefeeds or carriage returns will be enclosed in three double quotes (""").
Parameters
string $value:
Return value
string
1 call to EasyRdf_Serialiser_Turtle::quotedString()
- EasyRdf_Serialiser_Turtle::serialiseLiteral in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Serialiser/ Turtle.php - Given an EasyRdf_Literal object, convert it into a string, suitable to be written to a Turtle document. Supports multiline literals and literals with datatypes or languages.
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Serialiser/ Turtle.php, line 72
Class
- EasyRdf_Serialiser_Turtle
- Class to serialise an EasyRdf_Graph to Turtle with no external dependancies.
Code
public static function quotedString($value) {
if (preg_match('/[\\t\\n\\r]/', $value)) {
$escaped = str_replace(array(
'\\',
'"""',
), array(
'\\\\',
'\\"""',
), $value);
return '"""' . $escaped . '"""';
}
else {
$escaped = str_replace(array(
'\\',
'"',
), array(
'\\\\',
'\\"',
), $value);
return '"' . $escaped . '"';
}
}