lib/phlylabs/uctc.php
public static function convert($data, $from, $to, $safe_mode = false, $safe_char = 0xFFFC)
    {
        self::$safe_mode = ($safe_mode) ? true : false;
        self::$safe_char = ($safe_char) ? $safe_char : 0xFFFC;
        if (self::$safe_mode) self::$allow_overlong = true;
        if (!in_array($from, self::$mechs)) throw new Exception('Invalid input format specified');
        if (!in_array($to, self::$mechs)) throw new Exception('Invalid output format specified');
        if ($from != 'ucs4array') eval('$data = self::'.$from.'_ucs4array($data);');
        if ($to != 'ucs4array') eval('$data = self::ucs4array_'.$to.'($data);');
        return $data;
    }
public static function convert($data, $from, $to, $safe_mode = false, $safe_char = 0xFFFC)
    {
        self::$safe_mode = ($safe_mode) ? true : false;
        self::$safe_char = ($safe_char) ? $safe_char : 0xFFFC;
        if (self::$safe_mode) self::$allow_overlong = true;
        if (!in_array($from, self::$mechs)) throw new Exception('Invalid input format specified');
        if (!in_array($to, self::$mechs)) throw new Exception('Invalid output format specified');
        if ($from != 'ucs4array') eval('$data = self::'.$from.'_ucs4array($data);');
        if ($to != 'ucs4array') eval('$data = self::ucs4array_'.$to.'($data);');
        return $data;
    }
public static function convert ( $ data , $ from , $ to , $ safe_mode = false , $ safe_char = 0xFFFC ) { self :: $ safe_mode = ( $ safe_mode ) ? true : false ; self :: $ safe_char = ( $ safe_char ) ? $ safe_char : 0xFFFC ; if ( self :: $ safe_mode ) self :: $ allow_overlong = true ; if ( ! in_array ( $ from , self :: $ mechs ) ) throw new Exception ( 'Invalid input format specified' ) ; if ( ! in_array ( $ to , self :: $ mechs ) ) throw new Exception ( 'Invalid output format specified' ) ; if ( $ from != 'ucs4array' ) eval ( '$data = self::' . $ from . '_ucs4array($data);' ) ; if ( $ to != 'ucs4array' ) eval ( '$data = self::ucs4array_' . $ to . '($data);' ) ; return $ data ; }
The actual conversion routine

@param mixed $data  The data to convert, usually a string, array when converting from UCS-4 array
@param string $from  Original encoding of the data
@param string $to  Target encoding of the data
@param bool $safe_mode  SafeMode tries to correct invalid codepoints
@return mixed  False on failure, String or array on success, depending on target encoding
@access public
@since 0.0.1
The actual conversion routine