Thread: Problem with ASCII TABLE of Computer. Need Help

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    22

    Problem with ASCII TABLE of Computer. Need Help

    I have windows 7 x64, using DevC++, I can't find a good Ascii Table or I'm simply doing it wrong

    This is my problem ascii table
    I look the regular ascii table as reference, I tried using it to print some symbols but the decimal equivalence is different.
    Example: If I
    Code:
     
    int a1= 127;
    printf("a1 = %c", a1);
    /* This code simply print the character of its decimal value equivalence.
    The resulting is a black rectangle like in Dec 219 Hex DB */
    
    //Now I will try reverse ! that is 173
    int a1= 173;
    printf("a1 = %c", a1);
    /* It gives me a half size of 1, looks kinda an Iron. */
    Well thats practically my problem, what ascii table I should use or a good reference of an ascii table will help me a lot.

    Also is there a way for the arrow keys to have only a decimal equivalence, I tried experimenting, I scanf arrow keys and printed them but they give 2 decimal numbers.

    224 72 is the up key
    224 75 is the right key and so on.

    Thanks guys

  2. #2
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    When you are displaying characters outside of their normal range - that is, not simple digits or letters or established punctuation, then the look of the symbols are highly dependent on the font that's currently in effect. I usually start with the first ASCII table that Google returns: Ascii Table - ASCII character codes and html, octal, hex and decimal chart conversion and work from there. Notice than anything above 127 is 'Extended ASCII Codes' and really depend on the graphics hardware (in old systems it was hard-wired). As I said, the resident font can yield any variants on the symbols.

    As far as arrow keys, Ctrl, Alt etc they are not mapped to ASCII directly. You'll have to grab the keyboard scan codes which sometimes consist of 2 bytes.

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> I have windows 7 x64, using DevC++
    You can do better than DevC++, which is old and no longer maintained:
    wxDev-C++
    Code::Blocks
    Visual C++ 2010 Express | Microsoft Visual Studio

    >> what ascii table I should use or a good reference of an ascii table will help me a lot
    On Windows, these tables are called "codepages". For example, here is codepage 437: http://msdn.microsoft.com/en-us/goglobal/cc305156, which is equivalent to the "IBM PC extended ascii" table in your link.

    Here is the first thing you should read:
    http://www.joelonsoftware.com/articles/Unicode.html

    Then when you're ready to attempt outputting specific characters to the console, read this:
    Non-English characters with cout (post #22)

    Come back here if you have questions, need clarification, etc...

    gg

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Having problems with your computer's ASCII table? Are strange unwanted characters printing on your screen? This may be due to dust and dirt which decrease ASCII performance. First, power down your computer. On the back of your computer you should find a small rectangular button labeled "ASCII eject." Push this button. You should hear a clicking sound and the ASCII table will slide out of the side near the bottom of the case. Hold your hand next to the slot while ejecting as some computers (AMD-based systems in particular) will eject it with quite some force and you don't want it to fly across the room and break.

    The ASCII table will look like a small black ceramic disk approximately 8 centimeters across. Remove this from the ASCII port and clean it gently with hot water, dish soap and a soft-bristled toothbruth. Take care not to accidentally scratch it as you may introduce Japanese kana characters onto the ASCII table. Drip dry, ensuring that no soapy residue remains. Re-insert into the ASCII port and restart your computer. Your ASCII performance should be restored to new condition.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    You forgot rinse, repeat.

  6. #6
    Registered User
    Join Date
    Oct 2011
    Posts
    22
    @nonoob: Thanks for the info quite helpful, that's my problem with the arrow keys. In my project there is a menu and I want to use my arrow keys and enter to choose but I can't getch it because it gives to int and I'm still thinking how to get it right.

    @CodePlug: I know but my project should be run in DevC++ , I'm in college and this is like my "thesis" project. I want it to be the best that's why I'm going to an extra mile. Thanks for the links I will surely read this later. I will try to experiment on how to remove the 224 in the arrow keys, like in an if statement, I want it to get only the 80 not 224. If you have any ideas It will surely Helps.

    @brewbuck: I have no idea what you are talking about sorry, I use a laptop and there is no ascii eject or something but thanks anyway.
    This will be a good reference for future problems

  7. #7
    Registered User
    Join Date
    Oct 2006
    Posts
    250
    Quote Originally Posted by justin777 View Post
    @brewbuck: I have no idea what you are talking about sorry, I use a laptop and there is no ascii eject or something
    Priceless.
    iMalc: Your compiler doesn't accept misspellings and bad syntax, so why should we?
    justin777: I have no idea what you are talking about sorry, I use a laptop and there is no ascii eject or something

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Brewbuck is just being funny - pay no attention to that post unless you just want to laugh along.

    The arrow keys always show two bytes, instead of one. There is a way to work with this in Windows, but I haven't used it. The way I have done it requires the header file "conio.h", do you have it?

  9. #9
    Registered User
    Join Date
    Oct 2011
    Posts
    22
    @Adak oh I see, I thought most people here got Professionalism that's why I act it also. Yeah I have conio.h but I solve my problem, I did it like having a cdump
    it's like my first variable will get the 224 then the second is 74 etc. it will make my code lengthy but I think its worth it

  10. #10
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    > oh I see, I thought most people here got Professionalism that's why I act it also
    If you give me one hundred USD via Paypal I will personally perform an online (anonymous) virus scan on your computer. It will silently rid your system of any malware, and at the same time, speed it up considerably. For an additional fee of just $10.00, you can buy my proprietary internal cleaning software, which will calibrate the fan brushes to harmlessly eject dust from your drives.

    > Yeah I have conio.h but I solve my problem
    Get rid of conio.h. It's completely deprecated on *nix machines, and rarely even supported on newer Windows machines.

    > did it like having a cdump
    What? You're making no sense...

    > it's like my first variable will get the 224 then the second is 74 etc. it will make my code lengthy but I think its worth it
    No, that won't work. Here, look at this:
    Code:
    #include <termios.h>
    
    /* ... */
    
    void arrows (void) 
    {
    	int ch, i;
    	struct termios term;
    	
    	tcgetattr( STDIN_FILENO, &term );
    	term.c_lflag &= ~( ICANON | ECHO );
    	tcsetattr( STDIN_FILENO, TCSANOW, &term );
    	
    	for (i = 0; i < 4; i++) {
    		puts("enter arrow");
    		ch = 0;
    		ch += getchar() & 0xFF;
    		ch += getchar() & 0xFF;
    		ch += getchar() & 0xFF;
    		printf("%c | %d\n", ch, ch); 
    	}
    }
    Output:
    Code:
    enter arrow
    ? | 183 /* up */
    enter arrow
    ? | 184 /* dn */
    enter arrow
    ? | 186 /* left */
    enter arrow
    ? | 185 /* right */

  11. #11
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    So Justin is using Windows, and you give him an example for *nix?

    It's hypocritical to call conio.h deprecated, and then replace it with another non-standard include file, imo.

    By "no, that won't work", you mean "yes, it will work just fine". Interesting.

    Conio.h is alive and well on Windows 7 with Pelles C. XD

    Brewbuck's speel was funny, but the joke has gone quite stale now. Keep your day job, hey!

  12. #12
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    > So Justin is using Windows, and you give him an example for *nix?
    Sure, I was demonstrating the arrow key part which works for both. Only the termios stuff is *nix specific.

    > It's hypocritical to call conio.h deprecated, and then replace it with another non-standard include file, imo.
    Deprecated =/= non-standard. And termios =/= non-standard. It's not portable, if that's what you mean.

    > By "no, that won't work", you mean "yes, it will work just fine". Interesting.
    He was talking about multiple variables, I was talking about one variable.

  13. #13
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> I have windows 7 x64 ...
    I've yet to see Windows compiler that doesn't have conio.h - vendors try not to break existing code, no matter how old

    Code:
    #include <conio.h>
    #include <stdio.h>
    
    int main()
    {
        int c = 0;
        while (c != 'q' && c != 'e')
        {
            c = _getch();
            if (c == 0 || c == 0xe0)
            {
                int c2 = _getch();
                printf("[0x%02x,0x%02x]\n", (unsigned)c, (unsigned)c2);
            }//if
            else
            {
                printf("[0x%02x]\n", (unsigned)c);
            }//else
        }//while
    
        return 0;
    }//main
    Posix version of "_getch()" is here: while getch question Notice is sets VMIN, VTIME, and doesn't use getchar().

    gg

  14. #14
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    > vendors try not to break existing code, no matter how old
    OT, but Nmap Hackers: Microsoft Tightens the Noose on Raw Sockets

    And I was under the impression that MS was removing conio.h/dos.h support, guess not...

    > Notice is sets VMIN, VTIME, and doesn't use getchar().
    What's the advantage of this? Isn't getchar() portable anyway?

  15. #15
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Isn't getchar() portable anyway?
    Yes it is portable, but getchar() echos the output to the screen. The getch() function does not echo the data to the screen.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A faster ASCII table
    By cpjust in forum Tech Board
    Replies: 16
    Last Post: 03-25-2010, 02:28 PM
  2. ASCII Table
    By peckitt99 in forum C Programming
    Replies: 21
    Last Post: 10-09-2006, 01:53 AM
  3. help! extended ascii table
    By godhand in forum Linux Programming
    Replies: 7
    Last Post: 10-07-2003, 05:20 PM
  4. ASCII table going crazy?
    By Jamsan in forum Windows Programming
    Replies: 19
    Last Post: 03-27-2003, 02:33 AM
  5. need help with an ascii table =\
    By gsr squirrel in forum C++ Programming
    Replies: 9
    Last Post: 04-19-2002, 03:11 AM