henck / rtf-html-php

RTF to HTML converter in PHP
http://www.independent-software.com
GNU General Public License v2.0
102 stars 74 forks source link

Bad conversion in this case #76

Open Max84 opened 4 years ago

Max84 commented 4 years ago

RTF Translation is wrong in this case:

`<?php error_reporting(-1); ini_set('display_errors', 'on'); require DIR . '/vendor/autoload.php';

use RtfHtmlPhp\Document; use RtfHtmlPhp\Html\HtmlFormatter;

$original = "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}\viewkind4\uc1\pard\lang1036\f0\fs16 m\'e9lange ma\'efs fran\'e7ais\par}"; $document = new Document($original); // or use a string directly $formatter = new HtmlFormatter('UTF-8'); $r = $formatter->Format($document); file_put_contents('rtf.html', $r); echo $r; ?>`

Result:

tf1 onttbl 0 nil charset0 Microsoft Sans Serif; iewkind4 0 s16 mélange maïs français

Expected result: Something like "Mélange maïs français"

Thanks,

alecpl commented 3 years ago

Don't use double quotes for $original or replace every \ with \\.