You are here

function _notify_entity_to_utf8 in Notify 5

Same name and namespace in other branches
  1. 5.2 notify.module \_notify_entity_to_utf8()

File

./notify.module, line 504

Code

function _notify_entity_to_utf8($hex, $codepoint) {
  if ($hex != '') {
    $codepoint = base_convert($codepoint, 16, 10);
  }
  if ($codepoint < 0x80) {
    return chr($codepoint);
  }
  else {
    if ($codepoint < 0x800) {
      return chr(0xc0 | $codepoint >> 6) . chr(0x80 | $codepoint & 0x3f);
    }
    else {
      if ($codepoint < 0x10000) {
        return chr(0xe0 | $codepoint >> 12) . chr(0x80 | $codepoint >> 6 & 0x3f) . chr(0x80 | $codepoint & 0x3f);
      }
      else {
        if ($codepoint < 0x200000) {
          return chr(0xf0 | $codepoint >> 18) . chr(0x80 | $codepoint >> 12 & 0x3f) . chr(0x80 | $codepoint >> 6 & 0x3f) . chr(0x80 | $codepoint & 0x3f);
        }
      }
    }
  }
}