13

I've been tried to print Extended ASCII characters:

http://www.theasciicode.com.ar/

But all those symbols were printed as question-character on the white background ?.

I use the following cycle to print that symbols:

for (i = 0; i <= 30; i++)
    printf("%c", 201); 

Question: Is there any way to print those Extended ASCII characters or not? Or maybe there is special library for these characters?


OS Linux Ubuntu 13.04, Code::Blocks 12.11 IDE.

yulian
  • 1,601
  • 3
  • 21
  • 49
  • Extensions to ASCII are non-standard and best avoided. – Paul R Jun 28 '13 at 10:24
  • 2
    Do you want say that I have to avoid them? – yulian Jun 28 '13 at 10:25
  • hopefully a well configured terminal and ncurses will help. Emitting output depends on the terminal. WHat are you using? A PC ? A linux box with xterm ? – BigMike Jun 28 '13 at 10:26
  • @BigMike, So, the program prints that characters, but my terminal doesn't recognize them? – yulian Jun 28 '13 at 10:26
  • 1
    You don't *have* to avoid extended ASCII, but if you don't then you can expect a lot of problems with portability etc. – Paul R Jun 28 '13 at 10:26
  • @PaulR, Uh.. Understood. – yulian Jun 28 '13 at 10:27
  • 1
    @JulianKhlevnoy if you're on unix/linux, it depends also on the terminal you're using (Xterm or RXVT or VT100). If you're on DOS IIRC there was a device driver to manage such ascii exception. on Win32 honestly I don't know – BigMike Jun 28 '13 at 10:28
  • I tried some chars and heard a beeping from speaker. – huseyin tugrul buyukisik Jun 28 '13 at 10:28
  • The loop is not using `i`, it's printing codepoint 201 31 times. – unwind Jun 28 '13 at 11:25
  • @unwind, It uses. I want to print a bold line above and under matrix in order to make it easier to find in the output. – yulian Jun 28 '13 at 11:40
  • There is no “extended ASCII”. ASCII is an 7-bit encoding, which is represented in modern devices and protocols using 8-bit bytes with first bit set to zero. Any reference to “extended ASCII” should be read as “a misnomer for someone’s 8-bit character code, which is purported to coincide with ASCII in the first 128 positions”. – Jukka K. Korpela Jun 28 '13 at 18:25
  • @JukkaK.Korpela, I've got it. The answer suggests me to use Unicode - that is solution. Thanks for the information) I always glad for getting more knowledge. – yulian Jun 28 '13 at 20:51

1 Answers1

18

It's better to use unicode than extended ASCII, which is non-standard. A thread about printing unicode characters in C : printing-utf-8-strings-with-printf-wide-vs-multibyte-string-literals

But indeed you need to copy paste unicode characters..

A better way to start:

#include <stdio.h>

int main() {
    printf("\u2500\u2501\n");
}

See https://en.wikipedia.org/wiki/Box-drawing_character#Unicode for unicode characters for this extended ASCII style box art..

Community
  • 1
  • 1