protected function endsWithDynamic($function, $needle)
    {
        $enc = $this->getEncoding();
        $strlen = $this->length($enc);
        $testlen = mb_strlen($needle, $enc);

        if ($testlen <= $strlen)
        {
            return ($function($this->toString(), $needle, ($strlen-$testlen), $enc)!==false);
        }
        return false;
    }