WingDings font gives "iconv(): Detected an incomplete multibyte character in input string"
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 107
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in HtmlFormatter.php around line 375 and trace DecodeUnicode() for characters from the fcharset 128 WingDings definition. Reproduce the conversion with tekst2.rtf, then verify that CP932 multibyte input no longer causes iconv() to report an incomplete character and that HTML conversion completes without the exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100