Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 145139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:22:13+00:00 2026-05-11T08:22:13+00:00

I’m writing a piece of code which deals with math variables and indices, and

  • 0

I’m writing a piece of code which deals with math variables and indices, and I’d need to print subscripts and superscripts on a CLI, is there a (possibly cross-platform) way to do that? I’m working in vanilla C++.

Note: I’d like this to be cross-platform, but since from the first answers this doesn’t seem to be possible I’m working under MacOS and Ubuntu Linux (so bash).

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:22:14+00:00Added an answer on May 11, 2026 at 8:22 am

    Since most CLIs are really only terminals (pretty dumb ones mostly but sometimes with color), the only cross-platform way I’ve ever done this is by allocating muliple physical lines per virtual line, such as:

            2 f(x) = x  + log x                2 

    It’s not ideal but it’s probably the best you’re going to get without a GUI.

    Following you extra information as to what platforms you’re mainly interested in:

    With Ubuntu at least, gnome-terminal runs in UTF-8 mode by default so the following code shows how to generate the superscripts and subscripts:

    #include <stdio.h>  static char *super[] = {'\xe2\x81\xb0', '\xc2\xb9', '\xc2\xb2',     '\xc2\xb3', '\xe2\x81\xb4', '\xe2\x81\xb5', '\xe2\x81\xb6',     '\xe2\x81\xb7', '\xe2\x81\xb8', '\xe2\x81\xb9'}; static char *sub[] = {'\xe2\x82\x80', '\xe2\x82\x81', '\xe2\x82\x82',     '\xe2\x82\x83', '\xe2\x82\x84', '\xe2\x82\x85', '\xe2\x82\x86',     '\xe2\x82\x87', '\xe2\x82\x88', '\xe2\x82\x89'};  int main(void) {     int i;     printf ('f(x) = x%s + log%sx\n',super[2],sub[2]);     for (i = 0; i < 10; i++) {         printf ('x%s x%s ', super[i], sub[i]);     }     printf ('y%s%s%s z%s%s\n', super[9], super[9], super[9], sub[7], sub[5]);     return 0; } 

    The super and sub char* arrays are the UTF-8 encodings for the Unicode code points for numeric superscripts and subscripts (see here). The given program will output my formula from above (on one line instead of three), then another test line for all the choices and a y-super-999 and z-sub-75 so you can see what they look like.

    MacOS doesn’t appear to use gnome-terminal as a terminal program but references here and here seem to indicate the standard terminal understands UTF-8 (or you could download and install gnome-terminal as a last resort).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an app for my school newspaper, which is run completely online
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.