[yunqa.de] Re: Change charset in HTML-file using DIHtmlCharSetPlugin

  • From: Oleg <oleg-niko@xxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Fri, 07 Dec 2012 12:17:08 +0200

Hi,

Thank you for your answer. But I know about creation order. In my test project the components are in correct order. Perhaps problem in other. Try to open my demo project (DiHTMLCharset.zip from attach) and open any HTML file (or use HTML file from attach - !input.htm) which contains the following parameters of encoding:
At first line must be: <?xml version="1.0" encoding="Windows-1252"?>
Encoding of HTML must be: content="text/html; charset=Windows-1252" (meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" xmlns="" />) And try convert this file from Windows-1252 to UTF-8. The destination file will not change encoding of first line (xml tag). The first line will remain:
<?xml version="1.0" encoding="Windows-1252"?>
but must be:
<?xml version="1.0" encoding="UTF-8"?>

What is wrong?


Best Regards,
Oleg Litvinenko,
Software Developer
Gridinsoft LLC.


06.12.2012 20:17, Delphi Inspiration wrote:
On 06.12.2012 13:45, Oleg wrote:

and in OnCharSetChange event I can change charset:
   Sender.HtmlParser.HtmlTag.ValueOfNumber[ATTRIB_CONTENT_ID] :=
'text/html;charset=' +
UnicodeEncodings[Integer(cboTargetCharSet.Items.Objects[cboTargetCharSet.ItemIndex])].Name;
//Change to UTF-8

After performing all the operations I get a file:
!!!Encoding is not changed-----> <?xml version="1.0"
encoding="Windows-1252"?>
I suppose that your application triggers TDIHtmlWriterPlugin before the
TDIHtmlCharSetPlugin. This is a common oversight when dropping
components on a form in any order. Delphi takes this as the order in
which it creates non-visual components. This creation order determines
how TDIHtmlParser invokes its plugins.

You can easily change the creation order by right-clicking on the form
or datamodule and pick "Creation Order..." from the context menu. This
opens a dialog where should set up this order:

1. TDIHtmlParser
2. TDIHtmlCharSetPlugin
3. TDIHtmlWriterPlugin

Please consult the DIHtmlParser_CharSetConverter project as a reference.

The order of non-DIHtmlParser components does not matter in this context.

Ralf
_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa




Attachment: DiHTMLCharset.zip
Description: Binary data

Other related posts: