Since 'set term dumb' basically acts as a character cell terminal, any markup that doesn't fit in a character cell is problematic. That includes ^ (superscript) and _ (subscript). Raising or lowering by multiple character heights is particularly bad, and in fact can cause buffer overflows as shown by the following test case found by fuzzing:
gnuplot> set term dumb enh
Terminal type is now 'dumb'
Options are 'feed enhanced size 79, 24 aspect 2, 1 mono'
gnuplot> set title "C___@____________@__________5]
gnuplot> plot x
Segmentation fault (core dumped)
Possible ways to address this:
1) Disable enhanced mode for dumb.trm, or at least go back to making it not the default. This has the disadvantage that markup characters are printed as if they were normal text.
2) Ignore _ and ^ but otherwise process enhanced text as it is now
3) Recognize and replace some common cases like ^2 with ² [U+00B2 SUPERSCRIPT TWO] but otherwise ignore _ and ^. Unicode can handle numeric super- and sub-scripts, but not other simple cases like e^x. This would at least allow scientific format for axis tic labels. However I expect it would require a lot of code for an imperfect fix.
4) Limit super- and sub-scripting to a single level. This would probably fix the segfault bug, but doesn't resolve the larger problem.
I am inclined to go with (4). Anyone have other suggestions?
I aggree that (4) might be the best solution.
Last year, I had played with mapping characters to support "fonts" (Script/Fraktur/..) and font attributes (bold/italic/smallcaps) as well as super- and subscripts. The range of supported characters available is typically limited to the alphabet and numbers. For super- and subscripts character support even for this range incomplete. (But e^x would work btw.) Even worse is that the characters are from different ranges (ie. different purpose) and typically look inconsistent. See https://sourceforge.net/u/markisch/gnuplot/ci/dumb-uni-fonts/tree/ for the code.
For bold/italic support it is far superior to use terminal esacapes instead, see my merge-request https://sourceforge.net/p/gnuplot/gnuplot-main/merge-requests/18/ The escape sequence for this is actually widely supported by "terminal emulators". Unfortunately. this is not the case for the escapes for super- and subscripts.