Thread: Special characters

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    17

    Special characters

    I've always had problems outputting special characters on screen (e.g. é, à, ü , ç and such), whatever the language, compiler, etc.

    So, is there any way I could correctly print them on screen ?

  2. #2
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    well i use the ASCII value to do that...



    Example
    Code:
    char ch;
    for(int i=0;i<400;i++)
    {
    ch=i;
    cout<<ch;
    }

    You will get some beeps etc etc . aplhabets and the special characters..

  3. #3
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    pick the code you want from this program or go to asciitable.com

    Code:
    #include <iostream.h>
    
    #define NUL 0
    #define BEL 7
    #define BS 8
    #define TAB 9
    #define LF 10
    #define CR 13
    #define SUB 26
    #define SPC 32
    #define BLK 255
    #define ROWS 9
    #define COLUMNS 5
    
    int main(void)
    {
      const char ASCII_NAMES[ROWS][COLUMNS]={{"NUL \0"}, {"BEL \0"}, {"BS  \0"}, {"TAB \0"},
                                             {"LF  \0"}, {"CR  \0"}, {"SUB \0"}, {"SPC \0"},
                                             {"BLK \0"}
                                            };
      enum AsciiSubscript{MSG_NUL, MSG_BEL, MSG_BS, MSG_TAB, MSG_LF, MSG_CR, MSG_SUB,
                          MSG_SPC, MSG_BLK};
    
      const unsigned HEX_BASE = 16;
      unsigned AsciiNum = 0;
    
      printf("    ");
    
      for(unsigned i = 0; i <= HEX_BASE - 1; i++)
        printf("%02X  ", i);
    
      printf("\n");
    
      for(unsigned HexNum = 0; HexNum <= HEX_BASE - 1; HexNum++)
      {
        printf("%X0  ", HexNum);
    
        for(int Line=0; Line <= HEX_BASE - 1; Line++)
        {
          switch(AsciiNum)
          {
            case NUL : printf("%s", ASCII_NAMES[MSG_NUL]); break;
            case BEL : printf("%s", ASCII_NAMES[MSG_BEL]); break;
            case BS : printf("%s", ASCII_NAMES[MSG_BS]); break;
            case TAB : printf("%s", ASCII_NAMES[MSG_TAB]); break;
            case LF : printf("%s", ASCII_NAMES[MSG_LF]); break;
            case CR : printf("%s", ASCII_NAMES[MSG_CR]); break;
            case SUB : printf("%s",  ASCII_NAMES[MSG_SUB]); break;
            case SPC : printf("%s", ASCII_NAMES[MSG_SPC]); break;
            case BLK : printf("%s", ASCII_NAMES[MSG_BLK]); break;
            default : printf("%c   ", (char)AsciiNum);
          }
          AsciiNum++;
          if(Line == HEX_BASE -1)
            printf("\n");
        }
      }
      getchar();
    
      return 0;
    }
    Be a leader and not a follower.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  2. Special Characters
    By mikeman118 in forum Windows Programming
    Replies: 18
    Last Post: 12-09-2007, 12:49 PM
  3. special characters removing from srting
    By cnu_sree in forum C Programming
    Replies: 5
    Last Post: 06-06-2007, 08:30 PM
  4. Special characters and sending them to programs...
    By Dragoon_42 in forum C++ Programming
    Replies: 5
    Last Post: 01-23-2006, 04:49 PM
  5. Special (non) Keyboard Characters
    By TechWins in forum C++ Programming
    Replies: 3
    Last Post: 05-01-2002, 12:08 AM