Search code examples
phplaraveldompdficonvmbstring

Debug iconv_strlen error - PHP 5.5


I am trying to export a document to PDF using Laravel & DomPDF. This works on my mac, but not on staging or live server. Error as follows:

I have no idea what this means, and cannot find any solutions.

iconv_strlen(): Wrong charset, conversion from8bit//IGNORE' to UCS-4LE' is not allowed

open: /srv/www/html/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Mbstring.php

        return true;
    }

    static function mb_strlen($s, $encoding = INF)
    {
        INF === $encoding && $encoding = self::$internal_encoding;
        return iconv_strlen($s, $encoding . '//IGNORE');
    }

I have tried adding the following to .htaccess

AddDefaultCharset UTF-8

I have tried adding the following to the top of the view which I am trying to generate the pdf for:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

If you need any further information to assist me in debugging, please ask in comments.


Solution

  • Problem solved. Thanks BrianS.

    This was solved by re-installing mbstring.

    sudo yum --disablerepo="*" --enablerepo="remi*"
    install php-mbstring*
    sudo httpd -k restart