Thread: How to display extended ASCII characters in LINUX

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    4

    How to display extended ASCII characters in LINUX

    Hi.
    I need help displaying extended ASCII characters on a BASH prompt using the C programming language.
    I used to do this all the time when I had my windows notebook, but it crashed.
    I used this

    printf("%c", 178);

    but this only prints extended ASCII when using DOS or an emululator.
    The ASCII value or code 178 is a graphic type of character that won't display on bash with the above code.
    Is there a header file I can include and some different syntax that I could use to make this happen?

    Thanks.

  2. #2
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    587
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Another thread - http://cboard.cprogramming.com/c-pro...E-console.html

    I assume you're trying to print "▓", U+2593 DARK SHADE. On Linux, you could try:
    Code:
    #include <wchar.h>
    #include <locale.h>
    
    int main()
    {
        setlocale(LC_ALL, "");
        wprintf(L"\u2593\n");
        return 0;
    }
    gg

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    4
    When I run that code I get a warning that states-
    "universal character names are only valid in C++ and C99.
    Does this mean I will need the G++ compiler to use these characters?
    Thanks.

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    4
    I should probably state that I am running 32bit Ubuntu 9.10 with the most recent edition of GCC, I think its GCC 4.3 or 4.4 something??

  6. #6
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by mocatz187 View Post
    When I run that code I get a warning that states-
    "universal character names are only valid in C++ and C99.
    Does this mean I will need the G++ compiler to use these characters?
    Thanks.
    No. use:

    gcc -std=c99
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  7. #7
    Registered User
    Join Date
    Jan 2010
    Posts
    4
    Thanks Codeplug and MK27, thats exactly what I needed.
    And the article that stevesmithx pointed me to is very informative, I will read that several
    times.
    Thanks much everybody.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 03:27 AM
  2. Problem writing ASCII characters in file
    By sho1 in forum C++ Programming
    Replies: 5
    Last Post: 10-12-2006, 01:51 PM
  3. Replies: 11
    Last Post: 03-24-2006, 11:26 AM
  4. Inconsistent display of tab characters in edit control
    By New++ in forum Windows Programming
    Replies: 0
    Last Post: 01-06-2006, 08:34 AM
  5. All the ASCII characters
    By Shadow12345 in forum C++ Programming
    Replies: 5
    Last Post: 05-20-2002, 01:20 PM

Tags for this Thread