Topic: mb_convert_encoding(): Illegal character encoding specified

I am getting the following error in the log in a few places:

0:admin:JsHttpRequest.php:470: mb_convert_encoding(): Illegal character encoding specified

Looks like the problem is in JsHttpRequest::setEncoding (line 163). When $enc being passed is empty, the default value of $this->SCRIPT_ENCODING (which is respectable "windows-1251") is overwritten by an empty string.

And apparently mb_convert_encoding doesn't like an empty string. It's OK with missing third parameter, but not empty one.

When I wrapped "parse an encoding" in

if (!empty($enc)) { ... }

block, it seems to be working fine. Obviously, with English-only installation it is difficult to test how it behaves when encoding is actually set, but it works on my machine wink

The way this bug comes to the user - instead of a confirmation "Company was updated successfully" or similar, the user sees an orange warning sign

Re: mb_convert_encoding(): Illegal character encoding specified

Interesting, but I to fix this issue we need to know where the empty parameter is passed from.
Could you include following code before line 470 in file JsHttpRequest.php:

        _vl(debug_backtrace());

and cite the call stack stored in tmp/errors.log here?
Janusz

Re: mb_convert_encoding(): Illegal character encoding specified

Sure. A few things to point out (more for my curiosity):

  • Isn't it too late at line 470? By this time empty parameter is already set in $this->SCRIPT_ENCODING, and it is $this->SCRIPT_ENCODING which is an empty parameter that is passed in $fromenc. As my analysis shows in original post, that initial value is wiped out around line 163 (obviously, my analysis may be wrong)

  • The file is huge (~27 thousand lines; 1MB). Hard for me to say what part is significant.

  • I don't see the way to upload a file here. But you can get it from http://www.rabinovich.org/.outgoing/bug4177.tar.gz

Re: mb_convert_encoding(): Illegal character encoding specified

Thanks for info and sorry for the delay.
Seems you have something broken in your lang/installed_languages.inc file. Check following things:
. $dflt_lang should be set to locale existing in one of $intalled_languages array ('code' element)
. every $installed_languages elements should have valid 'encoding' value defined;
. records in 0_users table should have valid locale values in 'language' field.

Janusz