Skip to content

WingDings font gives "iconv(): Detected an incomplete multibyte character in input string" #96

@MircoBabin

Description

@MircoBabin

Reproduction

Convert file tekst2.zip using:

        $rtf = file_get_contents('tekst2.rtf');

        $document = new Document(rtrim($rtf, "\0"));  // remove ASCII 0, the NULL-byte.
        $formatter = new HtmlFormatter('UTF-8');
        $html = $formatter->Format($document);

This will throw an exception:

iconv(): Detected an incomplete multibyte character in input string at /.../public_html/vendor/henck/rtf-to-html/src/Html/HtmlFormatter.php:375

Analysis

  • On the first line "{\f1\fswiss\fcharset128 Wingdings;}" the WingDings font is defined with fcharset 128.
  • fcharset 128 is the Japanese Shift-JIS multibyte font. When the first character has a code of 128 or higher, the total character is compromised of two bytes.
  • HtmlFormatter.php is unware of the multibyte CP932 codepage. And calls DecodeUnicode() with only one character. iconv() then throws an exception, because only the half of the multibyte character was provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions