Page 1 of 1

Converting RTF to HTML with Webdings-Symbols

Posted: Mon Nov 26, 2018 2:29 pm
by rbom
Hello *,

I'm having an issue while converting RTF to HTML files. My HTML file show me some unknown characters instead of a Webdings-Symbol.

Can you help me?

Moreover, I will add two files two show my problem. The first file (Input.rtf) is the file which I'm trying to convert and the second (Output.txt) is my generated HTML file (renamed into a txt-file, because I could not upload HTML files), which shows the unknown characters.

In addition, I've analysed the problem a little bit deeper and I found the function
RVUnicodeToEncodedHTMLEx
in the
RVHtmlSave
-file. This function checks at the beginning if the given string is written in a symbol font.

If not: The text will be normally encoded. (This way is working for my Webdings-Symbols.)
Otherwise: The text is supposed to be converted into a known HTML-Symbol, but this is not working for my Webdings-Symbols.

Is there a way to avoid this behaviour? Or is there another way to convert my files.

Thank you for your help.

Re: Converting RTF to HTML with Webdings-Symbols

Posted: Tue Nov 27, 2018 9:44 am
by Sergey Tkachenko
Yes, when saving to HTML, TRichView converts the characters of the most important symbol fonts (including "Wingdings") to the corresponding Unicode character.
But I cannot reproduce the problem. What version of TRichView do you use?
I opened your RTF file in the ActionTest demo and exported it as "HTML - Simpified". The result: https://www.trichview.com/support/forum ... gChar.html
You can see your character (browsers may display it as an emoji icon). I used the newest version of TRichView and Delphi 10.3

But I also can see a header in your HTML file. Maybe HTML was corrupted when adding this header (for example the application that did it does not understand Unicode surrogate pairs, this pair is used to represent this character)?

Re: Converting RTF to HTML with Webdings-Symbols

Posted: Tue Nov 27, 2018 3:01 pm
by rbom
Hello,

I've created a small Testproject. This project cannot convert the symbols.

It is created with Delphi 2007 and I am using TRichView 17.5.2 .

The project contains only one function, which does the conversion.

For Testing: Place a path to a RTF-file into the edit field and hit the button. The converted HTML-file will be placed next to the input file.

Re: Converting RTF to HTML with Webdings-Symbols

Posted: Wed Nov 28, 2018 2:08 pm
by rbom
Hello,

I've analysed the problem a little bit further and I found out that the SaveOptions were different.

I've used the rvsoUTF8-Flag.

If I'm converting files without this flag, I will get a NCR Code for the symbol. In this case the code is "🏞".

I've got the problem that I'm not able to use this code. We were expecting an "P" at the same position instead of this code.

Is there away to prevent TRichView to convert the symbol to an unicode character.

Re: Converting RTF to HTML with Webdings-Symbols

Posted: Wed Nov 28, 2018 6:10 pm
by Sergey Tkachenko
I found the problem. It is in the Delphi's Utf8Encode function. In Delphi 6, 7 and 2007 it does not handle Unicode surrogate pairs correctly.
I'll fix this problem in the next update, I'll try to upload it tomorrow.

As for turning off conversion of symbol characters to Unicode, no, it is hard-coded. And writing "P" there is not a good option.
Back In the days when I started to implement symbol-to-Unicode conversion, all browsers displayed it as "P". Today I tested it with Edge, Chrome and FireFox. Edge and Chrome display the home character, while FireFox displays "P".
The solution with Unicode character is universal and is displayed correctly in all modern browsers.

Re: Converting RTF to HTML with Webdings-Symbols

Posted: Thu Nov 29, 2018 7:32 am
by rbom
Cool, thank you for your quick help. :D

Re: Converting RTF to HTML with Webdings-Symbols

Posted: Fri Nov 30, 2018 7:04 pm
by Sergey Tkachenko
Fixed in TRichView 17.6 (just uploaded)