RoundCube doesn't handle incorrectly labelled content encoding (displaying UTF-8 as latin-1)

Author: TotiTolvukallCreated Sep 16, 2026Updated Sep 16, 2026

Prerequisites

  • I have searched for duplicate or closed issues
  • I can recreate the issue with all plugins disabled

Describe the issue

The default install of RoundCube displays UTF-8 incorrectly when a mail-server mis-labels the content-type as "iso-8859-1[5]", not as "utf-8".

Remote Mail server is Exchange, default encoding is most likely 1252 or 8859-1, remote client is Outlook on a default Windows 11 install. Remote client sends email in Icelandic, body contains: "Sævör grét því úlpan varð ónýt."

Local Mail server is Stalwart. Stalwart does not mess around with changing encodings, what comes in goes out. Local client is RoundCube, default charset set to UTF-8, fallback character set also set from iso-8859-1 to utf-8. The received message from remote will display as "Sævör grét því úlpan verð ónýt."

The solution is a plugin overriding incorrectly chosen encoding;

plugins/fix_charset/fix_charset.php

class fix_charset extends rcube_plugin {
    public function init() {
        $this->add_hook('message_part_before', array($this, 'fix_body'));
    }

    public function fix_body($args) {
        if (!empty($args['body'])) {
            // Windows-1252 preserves the 0x80-0x9F byte range for uppercase Icelandic letters
            $args['body'] = mb_convert_encoding($args['body'], 'Windows-1252', 'UTF-8');
        }
        return $args;
    }
}

Enabling this plugin in config.inc.php ( $config['plugins'] = ['emoticons', 'fix_charset']; ) will preserve the actual content.

Note, way too many mail servers are using this incorrect setting, sending out UTF-8 email as 1252 so this should be included by default and documented that it is included - whether it is enabled by default or not is then up to the maintainers.

Additional note: Outlook (which is the dominant client here), Samsung mail and Apple mail all seem to resolve the issue by displayin the message correctly (in UTF-8) even if it's mis-labelled as Windows-1252.

What browser(s) are you seeing the problem on?

Edge, FireFox

What version of PHP are you using?

v8.4.24

What version of Roundcube are you using?

v1.6.19

JavaScript errors

No response

PHP errors

No response