You are here

public function rtf::escapeCharacter in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 modules/rtf/rtf_export.inc \rtf::escapeCharacter()
  2. 6 class_rtf.php \rtf::escapeCharacter()
  3. 7.2 modules/rtf/rtf_export.inc \rtf::escapeCharacter()

Convert special characters to ASCII.

1 call to rtf::escapeCharacter()
rtf::specialCharacters in modules/rtf/rtf_export.inc
Convert special characters to ASCII.

File

modules/rtf/rtf_export.inc, line 352

Class

rtf

Code

public function escapeCharacter($character) {
  $escaped = "";
  if (ord($character) >= 0x0 && ord($character) < 0x20) {
    $escaped = "\\'" . dechex(ord($character));
  }
  if (ord($character) >= 0x20 && ord($character) < 0x80 || ord($character) == 0x9 || ord($character) == 0xa) {
    $escaped = $character;
  }
  if (ord($character) >= 0x80 and ord($character) < 0xff) {
    $escaped = "\\'" . dechex(ord($character));
  }
  switch (ord($character)) {
    case 0x5c:
    case 0x7b:
    case 0x7d:
      $escaped = "\\" . $character;
      break;
  }
  return $escaped;
}