ANSI output

This is a discussion on ANSI output within the C++ Programming forums, part of the General Programming Boards category; Pianorain: no need to apologise....

  1. #16
    Registered User
    Join Date
    Mar 2005
    Posts
    26
    Pianorain: no need to apologise.

  2. #17
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    There are only a certain number of ASCII characters that can be printed, given any OS and any compiler that is based on ASCII.

    There may be a certain subset more that can be printed, based soley on OS and compiler.

    Code:
            ☺       ☻       ♥       ♦       ♣       ♠
    
            ♫       ☼       ►       ◄       ↕       ‼                     ▬
    ↨       ↑       ↓       →       ←       ∟       ↔       ▲       ▼
    !       "       #       $       %       &       '       (       )       *
    +       ,       -       .       /       0       1       2       3       4
    5       6       7       8       9       :       ;       <       =       >
    ?       @       A       B       C       D       E       F       G       H
    I       J       K       L       M       N       O       P       Q       R
    S       T       U       V       W       X       Y       Z       [       \
    ]       ^       _       `       a       b       c       d       e       f
    g       h       i       j       k       l       m       n       o       p
    q       r       s       t       u       v       w       x       y       z
    {       |       }       ~       ⌂
    That was the output from the program below on a Windows 2003 Small Business Server OS using Microsoft Visual C++ Toolkit 2003.

    Code:
    #include <iostream>
    
    int main()
    {
    	for (int x = 0; x < 128; x++)
    	{
    		std::cout << (char)x << "\t";
    	}
    	
    	std::cin.get();
    	return(0);
    }
    So no. Not every character in ASCII can be displayed on all implimentations.

  3. #18
    email for MystWind avatar MystWind's Avatar
    Join Date
    Feb 2005
    Location
    Holland , The Hague
    Posts
    88
    Quote Originally Posted by sufthingol
    stop holding back info
    totally lol .:P hmm dunno if this might help but this is my ASCII listing program I always use :

    Code:
     
    #include <iostream>               // says that we are going to use cout 
    #include <conio.h>                // used for getch():
    #include <windows.h> // says were going to use some colours
                          // allows us to use getch(); 
    using namespace std;
    
    int main()
    {
      int y ;
      //-------------declares the colours were going to use -------------//
      
          HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
        WORD wOldColorAttrs;
        CONSOLE_SCREEN_BUFFER_INFO csbiInfo; 
        
    
        
      //--------------------generates the ASCII list--------------------//
      
      for ( int x = 0; x < 257; x++ ) { // declares x , adds 1 to x while x is smaller than 256 //
       
                  SetConsoleTextAttribute ( h, FOREGROUND_BLUE | FOREGROUND_INTENSITY ); 
       
        cout<< x <<".) " ;
        
                  SetConsoleTextAttribute ( h, FOREGROUND_GREEN | FOREGROUND_INTENSITY ); 
        
        cout << (char)x << endl ; // shows wich number corrospontents with the ASCII number // 
        
      }
      
      // some copyright :P  
      
                SetConsoleTextAttribute ( h, FOREGROUND_RED | FOREGROUND_INTENSITY );    
          cout << endl << "written by " ;
              SetConsoleTextAttribute ( h, FOREGROUND_BLUE | FOREGROUND_INTENSITY );  
          cout << "MystWind "<< (char)184 ; // (char)184 stands for nr. 184 in the ASCII listing ; copyright.
          
    
      getch(); // this doesn't closes the program until you press a key.
    }
    so whats the problem with just 95 characters being displayed?
    I can;t compile your program though , because of the cursus libary
    PLay MystWind beta , within two years

  4. #19
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    Did that ever strike you as needlessly complicated, Myst?

  5. #20
    Registered User
    Join Date
    Mar 2005
    Posts
    26
    Apparently there is a video mode that let's you display those glyphs directly. A programmer known as Tim Sweeny did it in his dos program ZZT. I wish I knew how he did it. He was using Pascal btw.

  6. #21
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Somehow ZZT made it onto the list of "Top 100 DOS Games". That better be why.

  7. #22
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    I can't say I know how this can be done without creating a font yourself and doing some manual rendering, or using some Windows API functionality (or other 3rd party libraries, like the curses one you're using perhaps). After all, there are characters that hold special functions such as '\0' (as has been mentioned), '\a', '\t', '\b', and all the other escape sequences as well. If you try outputting any of them, they will almost certainly not display single characters as you might expect.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  8. #23
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    Quote Originally Posted by sufthingol
    Apparently there is a video mode that let's you display those glyphs directly. A programmer known as Tim Sweeny did it in his dos program ZZT. I wish I knew how he did it. He was using Pascal btw.
    He also went on to help start Epic Megagames, now known simply as Epic Games, the makers if the Unreal Engine (and series).
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

  9. #24
    Registered User
    Join Date
    Mar 2005
    Posts
    26
    I have found out how to do it.

    Code:
    int a = 0;
      do
      {
        addch(a | A_ALTCHARSET);refresh();
        ++a;
      }
      while (a < 256);getch();
    http://img.photobucket.com/albums/v3...ic/charmap.jpg

  10. #25
    email for MystWind avatar MystWind's Avatar
    Join Date
    Feb 2005
    Location
    Holland , The Hague
    Posts
    88

    Red face

    Quote Originally Posted by Lithorien
    Did that ever strike you as needlessly complicated, Myst?
    NO its NOT needlessly complicated : check the out put , its better than any other ASCII output listing programs.

    p.s congratz suftingol
    Last edited by MystWind; 03-10-2005 at 09:42 AM.
    PLay MystWind beta , within two years

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 02:08 PM
  2. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 02:29 PM
  3. Replies: 4
    Last Post: 11-30-2005, 03:44 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 04:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21