You are here

protected function EasyRdf_Serialiser_Ntriples::escapedChar in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Ntriples.php \EasyRdf_Serialiser_Ntriples::escapedChar()

@ignore

1 call to EasyRdf_Serialiser_Ntriples::escapedChar()
EasyRdf_Serialiser_Ntriples::escapeString in vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Ntriples.php
@ignore

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Ntriples.php, line 105

Class

EasyRdf_Serialiser_Ntriples
Class to serialise an EasyRdf_Graph to N-Triples with no external dependancies.

Code

protected function escapedChar($c) {
  $no = $this
    ->unicodeCharNo($c);

  /* see http://www.w3.org/TR/rdf-testcases/#ntrip_strings */
  if ($no < 9) {
    return "\\u" . sprintf('%04X', $no);

    /* #x0-#x8 (0-8) */
  }
  elseif ($no == 9) {
    return '\\t';

    /* #x9 (9) */
  }
  elseif ($no == 10) {
    return '\\n';

    /* #xA (10) */
  }
  elseif ($no < 13) {
    return "\\u" . sprintf('%04X', $no);

    /* #xB-#xC (11-12) */
  }
  elseif ($no == 13) {
    return '\\r';

    /* #xD (13) */
  }
  elseif ($no < 32) {
    return "\\u" . sprintf('%04X', $no);

    /* #xE-#x1F (14-31) */
  }
  elseif ($no < 34) {
    return $c;

    /* #x20-#x21 (32-33) */
  }
  elseif ($no == 34) {
    return '\\"';

    /* #x22 (34) */
  }
  elseif ($no < 92) {
    return $c;

    /* #x23-#x5B (35-91) */
  }
  elseif ($no == 92) {
    return '\\';

    /* #x5C (92) */
  }
  elseif ($no < 127) {
    return $c;

    /* #x5D-#x7E (93-126) */
  }
  elseif ($no < 65536) {
    return "\\u" . sprintf('%04X', $no);

    /* #x7F-#xFFFF (128-65535) */
  }
  elseif ($no < 1114112) {
    return "\\U" . sprintf('%08X', $no);

    /* #x10000-#x10FFFF (65536-1114111) */
  }
  else {
    return '';

    /* not defined => ignore */
  }
}