function fp_utf8_encode

7.x misc.inc fp_utf8_encode(string $s)
1 call to fp_utf8_encode()
Course::load_descriptive_data in classes/Course.php
This function will load $this will all sorts of descriptive data from the database. For example, hours, title, description, etc.

File

includes/misc.inc, line 37
This file contains misc functions for FlightPath

Code

function fp_utf8_encode(string $s) {
  $s .= $s;
  $len = \strlen($s);

  for ($i = $len >> 1, $j = 0; $i < $len; ++$i, ++$j) {
    switch (true) {
      case $s [$i] < "\x80":
        $s [$j] = $s [$i];
        break;
      case $s [$i] < "\xC0":
        $s [$j] = "\xC2";
        $s [++$j] = $s [$i];
        break;
      default:
        $s [$j] = "\xC3";
        $s [++$j] = \chr(\ord($s [$i]) - 64);
        break;
    }
  }

  return substr($s, 0, $j);
}