Author Topic: patch for [source_exporter]  (Read 246 times)

Online srm2000

  • Single posting newcomer
  • *
  • Posts: 3
patch for [source_exporter]
« on: Yesterday at 10:11:33 am »
The original version of exporter.dll is not friend to unicode characters.
The encoding is changed from "iso-8859-1" to "utf-8" and it works  well.
Hope the adoption in next Nightly builds.

--- E:\codeblocks-SVN-work\SVN13739_org_locked\src\plugins\contrib\source_exporter\htmlexporter.cpp  2025-10-08 15:29:03.197953500 +0800
+++ E:\codeblocks-SVN-work\SVN13739_editing\src\plugins\contrib\source_exporter\htmlexporter.cpp     2025-10-08 14:44:22.688643200 +0800
@@ -55,13 +55,13 @@
 };

 const char *HTMLExporter::HTMLHeaderBEG =
-  "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
+  "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
   "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
   "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
   "<head>\n";

 const char *HTMLExporter::HTMLMeta =
-  "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n"
+  "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"
   "<meta name=\"generator\" content=\"Code::Blocks Exporter plugin\" />\n";

 const char *HTMLExporter::HTMLStyleBEG =

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1776
Re: patch for [source_exporter]
« Reply #1 on: Yesterday at 12:25:39 pm »
Thanks for the patch, but IMHO this is not so easy. The encoding must match the one used in the StyledTextCtrl, if you are using ISO8859-1 then you must convert it to UTF-8 or use ISO8859-1 in the HTML header.

An additional problem is that the encoding may change within the document, as it is a property of the style used.

One possible solution is applying your patch and converting char-by-char t the text to UTF-8 in HTMLExporter.cpp:276 (if it is not already UTF-8).

EDIT: Looks like Scintilla (the base for wxStyledTextCtrl) uses UTF-8 iinternally, so you patch may be enough. I will test with ISO8859 and Windows1252 external encodings.
« Last Edit: Yesterday at 01:14:45 pm by Miguel Gimenez »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1776
Re: patch for [source_exporter]
« Reply #2 on: Yesterday at 03:04:10 pm »
Applied in r13743, thank you.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6098
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: patch for [source_exporter]
« Reply #3 on: Today at 05:10:01 am »
Hi, srm2000, nice work!
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.