diff --git a/doc/dox/todo.dox b/doc/dox/todo.dox
index b8b46b0d44..6c0d7dfaa1 100644
--- a/doc/dox/todo.dox
+++ b/doc/dox/todo.dox
@@ -39,7 +39,6 @@ This page lists several todos and wishes for future version of JKQTPlotter
JKQTMathText:
- - add instruction for unicode-characters \\charDDDD, \\char"XXXX ...
- check sub/superscript with italic text in math mode, possibly a correction is necessary
- explore where QFontMetricsF::horizontalAdvance() can be used (for Qt >=5.15)
- add support for \\bigl,\\bigr,\\Bigr,... commands for fixed-size but large paramtheses
diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox
index a28ebda9a4..68b19c3566 100644
--- a/doc/dox/whatsnew.dox
+++ b/doc/dox/whatsnew.dox
@@ -73,6 +73,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
- NEW: added support for flushleft/flushright/center-environments with linebreaks
- NEW: added support for framed/shaded/snugshade-environments with linebreaks and framed
- NEW: added support for -- and --- for en- and em-dashes
+ - NEW: added support for \c \\char"HEX , \c \\char'OCTAL and \c \\charDECIMAL for inserting any uicode character code
diff --git a/doc/images/jkqtmathtext/jkqtmathtext_char.png b/doc/images/jkqtmathtext/jkqtmathtext_char.png
new file mode 100644
index 0000000000..f1fc08924d
Binary files /dev/null and b/doc/images/jkqtmathtext/jkqtmathtext_char.png differ
diff --git a/examples/jkqtmathtext_test/testform.cpp b/examples/jkqtmathtext_test/testform.cpp
index 0fcb5f4089..3cd5dc6838 100644
--- a/examples/jkqtmathtext_test/testform.cpp
+++ b/examples/jkqtmathtext_test/testform.cpp
@@ -68,6 +68,8 @@ TestForm::TestForm(QWidget *parent) :
ui->cmbTestset->addItem("text (bold)", "text \\mathbf{bold}");
ui->cmbTestset->addItem("textcolor", "text \\mathbf{bold}\\textcolor{red}{RED}");
ui->cmbTestset->addItem("userfont", "text, \\userfont{Arial}{Arial}, \\userfont{Comic Sans MS}{Comic Sans MS}");
+ ui->cmbTestset->addItem("text: \\char", "A: \\char65, circonflex: \\char\"109 accent: \\char\'351");
+ ui->cmbTestset->addItem("math: \\char", "A: $\\char65$, circonflex: $\\char\"109$ accent: $\\char\'351");
ui->cmbTestset->addItem("unicode", "star: \\unicode{2605}, circonflex: \\unicode{109} emoticons: \\usym{1F440} \\usym{1F929}");
ui->cmbTestset->addItem("UTF8", "star: \\utfeight{e29885} emoticons \\utfeight{F09F9881} \\utfeight{f09f98bb}");
const auto mathDecoExample=[](const QString& deco)->QString { return "\\"+deco+"{x}\\"+deco+"{i}\\"+deco+"{X}\\"+deco+"{\\psi}\\"+deco+"{abc}"; };
diff --git a/lib/jkqtcommon/private/jkqtcommon_precomp.h b/lib/jkqtcommon/private/jkqtcommon_precomp.h
index cb977877e6..06ccba6f6a 100644
--- a/lib/jkqtcommon/private/jkqtcommon_precomp.h
+++ b/lib/jkqtcommon/private/jkqtcommon_precomp.h
@@ -70,8 +70,16 @@
#include
#include
#include
+#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
+#include
+#include
+#else
+#include
+#endif
+
#include "jkqtcommon/jkqtpmathtools.h"
#include "jkqtcommon/jkqtpcodestructuring.h"
#include "jkqtcommon/jkqtpdebuggingtools.h"
+#include "jkqtcommon/jkqtpstringtools.h"
#endif // jkqtcommon_precomp_h
diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp
index dfa9541e12..43c62d4b0b 100644
--- a/lib/jkqtmathtext/jkqtmathtext.cpp
+++ b/lib/jkqtmathtext/jkqtmathtext.cpp
@@ -1301,7 +1301,8 @@ JKQTMathText::tokenType JKQTMathText::getToken() {
if (c=='\\') {
//----------------------------------------------------------
// parsing accent instructions like \ss \"{a} ...
- if (!parsingMathEnvironment){
+ const QString next5=parseString.mid(currentTokenID, 5);
+ if (!parsingMathEnvironment && next5!="\\char"){
for (int len: accentLetters_LenBackslash) {
const QString acc=parseString.mid(currentTokenID, len);
if (acc.size()==len && accentLetters.contains(acc)) {
@@ -1343,6 +1344,47 @@ JKQTMathText::tokenType JKQTMathText::getToken() {
if (currentTokenName.size()==0) error_list.append(tr("error @ ch. %1: parser encountered empty istruction").arg(currentTokenID));
if (currentTokenName=="newline") return MTTinstructionNewline;
if (currentTokenName=="linebreak") return MTTinstructionNewline;
+ if (currentTokenName=="char") {
+ QString num="";
+ currentTokenID++;
+ c=parseString[currentTokenID];
+ if (c=='"') {
+ // match '\char"HEXDIGITS'
+ currentTokenID++;
+ c=parseString[currentTokenID];
+ while ((currentTokenIDA: \\char65, circonflex: \\char\"109 accent: \\char\'351)
- \c \\unicode{HEX} and \c \\usym{HEX} : draws a unicode character from its 32-bit codepoint \image html jkqtmathtext/jkqtmathtext_unicode.png (generated by star: \\unicode{2605}, circonflex: \\unicode{109} emoticons: \\usym{1F440} \\usym{1F929}
)
- \c \\utfeight{HEX} : draws a unicode character from its UTF-8 encoding \image html jkqtmathtext/jkqtmathtext_utf8.png (generated by star: \\utfeight{e29885} emoticons \\utfeight{F09F9881} \\utfeight{f09f98bb}
)
- \c ^{...} \c _{...} : display the contents of braces in superscript/subscript \image html jkqtmathtext/jkqtmathtext_supersub.png