You are here

function _link_code2utf in Link 6.2

Returns the utf string corresponding to the unicode value.

Needed for handling utf characters in PHP4.

See also

http://www.php.net/manual/en/function.html-entity-decode.php#75153

File

./link.inc, line 294
Helper functions for Link field, widget and form elements.

Code

function _link_code2utf($num) {
  if ($num < 128) {
    return chr($num);
  }
  if ($num < 2048) {
    return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
  }
  if ($num < 65536) {
    return chr(($num >> 12) + 224) . chr(($num >> 6 & 63) + 128) . chr(($num & 63) + 128);
  }
  if ($num < 2097152) {
    return chr(($num >> 18) + 240) . chr(($num >> 12 & 63) + 128) . chr(($num >> 6 & 63) + 128) . chr(($num & 63) + 128);
  }
  return '';
}