public function escapeLiteral($s)
 {
     $escaped = addcslashes($s, "..\"\\");
     if ($this->escaper !== null) {
         $escaped = $this->escaper->escapeString($escaped);
     }
     return $escaped;
 }
Beispiel #2
0
 public function escapeLiteral($s)
 {
     // String escapes. Note that the N3 spec is more restrictive than the Turtle and TR
     // specifications, see <https://www.w3.org/TeamSubmission/n3/#escaping>
     // and <https://www.w3.org/TR/turtle/#string>
     // and <https://www.w3.org/TR/n-triples/#grammar-production-literal>.
     // Allowed escapes according to the N3 spec are:
     // ECHAR	::=	'\' [tbnrf"'\]
     // The single quote however does not require escaping when used in double quotes.
     $escaped = strtr($s, array("" => '\\u0000', "" => '\\u0001', "" => '\\u0002', "" => '\\u0003', "" => '\\u0004', "" => '\\u0005', "" => '\\u0006', "" => '\\u0007', "" => '\\b', "\t" => '\\t', "\n" => '\\n', "\v" => '\\u000B', "\f" => '\\f', "\r" => '\\r', "" => '\\u000E', "" => '\\u000F', "" => '\\u0010', "" => '\\u0011', "" => '\\u0012', "" => '\\u0013', "" => '\\u0014', "" => '\\u0015', "" => '\\u0016', "" => '\\u0017', "" => '\\u0018', "" => '\\u0019', "" => '\\u001A', "" => '\\u001B', "" => '\\u001C', "" => '\\u001D', "" => '\\u001E', "" => '\\u001F', '"' => '\\"', '\\' => '\\\\'));
     if ($this->escaper !== null) {
         $escaped = $this->escaper->escapeString($escaped);
     }
     return $escaped;
 }