this can throw errors is mbstring is not available.

I would check for it first then use it, like:

    $diff = (function_exists('mb_strlen'))? strlen($value) - mb_strlen($value) : 0;