Code::Blocks Forums
Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: srm2000 on October 08, 2025, 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 =
-
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.
-
Applied in r13743 (https://sourceforge.net/p/codeblocks/code/13743/), thank you.