How to use symbols of extended ASCII table in C?
Asked Answered
D

1

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.

Defloration answered 28/6, 2013 at 10:22 Comment(12)
Extensions to ASCII are non-standard and best avoided.Pascual
Do you want say that I have to avoid them?Defloration
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 ?Suggestion
@BigMike, So, the program prints that characters, but my terminal doesn't recognize them?Defloration
You don't have to avoid extended ASCII, but if you don't then you can expect a lot of problems with portability etc.Pascual
@PaulR, Uh.. Understood.Defloration
@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 knowSuggestion
I tried some chars and heard a beeping from speaker.Deceleron
The loop is not using i, it's printing codepoint 201 31 times.Omnivore
@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.Defloration
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”.Nehemiah
@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.Defloration
F
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..

Flexuous answered 28/6, 2013 at 10:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.