473,509 Members | 3,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Beginner Question: ASCII Symbols

Beginner Question: ASCII Symbols

I am using Borland C++ and programming under DOS. I wish to display the
symbols of the early ASCII character set...

For example:

cout << char(7);

Obviously this is assigned to the BELL signal and therefore sounds the beep
and doesn't display the bullet point I require. I also require displaying a
of these symbols - Is anyone able to help with a solution to this problem?

Responses are greatly appreciated

Andy
Oct 13 '07 #1
6 5385
Andy Leese wrote:
I am using Borland C++ and programming under DOS.
Why?
cout << char(7);

Obviously this is assigned to the BELL signal and therefore sounds the beep
and doesn't display the bullet point I require.
The ASCII standard does not define a "bullet point" character, so you
are out of luck.

Unicode would support it, but DOS doesn't support unicode.
Oct 13 '07 #2
On Oct 13, 11:18 am, "Andy Leese" <and...@lycos.comwrote:
Beginner Question: ASCII Symbols

I am using Borland C++ and programming under DOS. I wish to display the
symbols of the early ASCII character set...

For example:

cout << char(7);

Obviously this is assigned to the BELL signal and therefore sounds the beep
and doesn't display the bullet point I require. I also require displaying a
of these symbols - Is anyone able to help with a solution to this problem?

Responses are greatly appreciated

Andy
The easiest way is to use a is_printable function (your own or Google
around for one)

char charprint(char c)
{
if (is_printable())return c:
return '#';//something printable
}

cout<<charprint('b');//etc

}
Oct 14 '07 #3
>I am using Borland C++ and programming under DOS.
>
Why?
I have Borland C++ and wish to write a program in DOS. Are you suggesting
this isn't ideal?
> cout << char(7);

Obviously this is assigned to the BELL signal and therefore sounds the
beep
and doesn't display the bullet point I require.

The ASCII standard does not define a "bullet point" character, so you
are out of luck.

Unicode would support it, but DOS doesn't support unicode.
What I don't understand is I have a program written in Pascal (running in
pure DOS or DOS Console) that displays these characters perfectly. I also
find that using my Hex Editor (in pure DOS and a DOS Console in Windows)
that I can enter the hex value and the bullet character (and all the others)
displays fine. So surely DOS can display these characters?

It seems a possible solution to this problem may be to 'turn off'
interpretation of the characters that are output. I believe this may be
possible by changing the output stream to binary mode, but I'm not sure how
to do this. Any further ideas appreciated.

Andy
Oct 15 '07 #4
Andy Leese wrote:
>>I am using Borland C++ and programming under DOS.
>> cout << char(7);

Obviously this is assigned to the BELL signal and therefore sounds the
beep
and doesn't display the bullet point I require.
The ASCII standard does not define a "bullet point" character, so you
are out of luck.

Unicode would support it, but DOS doesn't support unicode.

What I don't understand is I have a program written in Pascal (running in
pure DOS or DOS Console) that displays these characters perfectly. I also
find that using my Hex Editor (in pure DOS and a DOS Console in Windows)
that I can enter the hex value and the bullet character (and all the others)
displays fine. So surely DOS can display these characters?

It seems a possible solution to this problem may be to 'turn off'
interpretation of the characters that are output. I believe this may be
possible by changing the output stream to binary mode, but I'm not sure how
to do this. Any further ideas appreciated.
At this point, you are out of the realm of the C++ language, and into
compiler and OS specifics. May I suggest you ask further in a newsgroup
with either "borland" or "msdos" in its name?

See FAQ 5.9
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9 for some
suggested groups.
Oct 15 '07 #5
Andy Leese wrote:
>>I am using Borland C++ and programming under DOS.
Why?

I have Borland C++ and wish to write a program in DOS. Are you suggesting
this isn't ideal?
I was subtly suggesting that in the long run it might be a better idea
to use a non-obsolete OS to make such programs, especially if you are
dealing with things like character sets (which DOS as horrible and
completely outdated support for). But whatever floats your boat.
Oct 15 '07 #6
On Mon, 15 Oct 2007 20:05:03 +0100, Andy Leese wrote:
What I don't understand is I have a program written in Pascal (running in
pure DOS or DOS Console) that displays these characters perfectly. I also
find that using my Hex Editor (in pure DOS and a DOS Console in Windows)
that I can enter the hex value and the bullet character (and all the others)
displays fine. So surely DOS can display these characters?
As others have pointed out, your question is off-the-topic in this
newsgroup.

However, I can imagine it being difficult getting a definite answer
to your question, so I'll explain it for you.

In Borland Pascal, if you use the CRT unit, it will use a "direct video"
feature which means that when you print characters, it will poke the
character values corresponding to those characters directly into the
video memory. In the PC hardware, the video memory is not a teletype
device, so it actually defines graphical glyphs for each 256 different
bytes that can be poked into the text mode video memory.
That set of glyphs is defined by the computer manufacturer or the
operating system provider; in most cases on the IBM PC, it was
the Extended ASCII set, also called CP437. [1]
By poking the video memory, you can even display the glyph #13, which
normally is interpreted as carriage return, and the glyph #10, which
normally is interpreted as a newline.

However, in actual ASCII [2], the first 32 bytes of the character set
are reserved for control codes. In the Extended ASCII set that
region contains symbols only because of the reason explained above.

The C++ language is not designed for PC hardware in particular, or
any hardware in particular at all. Most commonly though, when you
output to stdout or std::cout in C++, it will write into what is
being simulated as a teletype device, where those control codes
in 0..31 range actually are handled as control codes.

However, std::cout may also correspond to a file, or to another
program's input, or something else. It depends on the operating
system.

There is no "C++" way to do anything device or hardware specific.

Outputting control codes by poking them directly into the video memory
would really be a hardware and environment specific thing; Borland C++
for MS-DOS may provide such a feature, but I wouldn't count on it.

Still, the question remains, why do you use such an obsolete compiler
environment?
If you actually _need_ to be writing to a DOS environment (for example,
some legacy machine that is operated in a booth somewhere), then by
all means you can study the hardware features and utilize them, but
keep in mind that they are compiler specific, and hardware specific;
such tricks do not work on different compilers (generally speaking),
and not in different environments. For example, if your program pokes
into the video memory, and later, you decide to compile it as a WIN32
application (even if a console program), it will not work.
Any assumptions you make on the running environment will hinder your
chances of porting the application to a different environment.
Sticking with the C++ standard (knowing what it guarantees and what
it does not guarantee (i.e. what it makes no mention of)) is the best
way to ensure your program works on whatever platform it is compiled on.

Last, I would have quoted a relevant section in the newsgroup's FAQ [3],
but I couldn't find anything particularly fitting here.
[1]: http://en.wikipedia.org/wiki/CP437
[2]: http://en.wikipedia.org/wiki/ASCII
[3]: http://www.parashift.com/c++-faq-lite/

--
Joel Yliluoma - http://bisqwit.iki.fi/
: comprehension = 1 / (2 ^ precision)
Oct 16 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2913
by: Rensjuh | last post by:
Hello, does someone have / know a good C++ tutorial for beginnners? I would prefer Dutch, but English is also fine. Hoi, heeft / kent iemand nog een goede C++ tutorial voor beginners? Het liefste...
37
10115
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be...
5
3601
by: Gidi | last post by:
Hi, 1. I have a string that i want to write into a file. the string is build from few textboxs (str=text1+text2...), how can i write the string to the file in ASCII format? 2. I need my...
61
4866
by: Christoph Zwerschke | last post by:
On the page http://wiki.python.org/moin/Python3%2e0Suggestions I noticed an interesting suggestion: "These operators ≤ ≥ ≠ should be added to the language having the following meaning: ...
15
2283
by: Notre Poubelle | last post by:
Hello, I have a large legacy MFC application. As is typical, there is an executable along with several MFC DLLs. One of these DLLs is created by staticly linking in many libraries resulting in...
3
6026
by: devgrt | last post by:
C#: I have a buffer that is populated with char data from a DLL: byte ret = new byte; I want to convert to a C# string: string msg = Encoding.ASCII.GetString(ret, 0, ret.Length); The problem...
8
8815
by: > Adrian | last post by:
How do I use System.Text.Encoding.Default in conjunction with "append"? The objective being not to get into all sorts of problems with special ASCII characters like é etc. Many thanks, Adrian.
399
12635
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
4
2618
by: Gernot Frieslinger | last post by:
Hi all! I am a beginner to C++ DotNet and I would like to ask what "Symbols not loaded" means and how to solve this problem. Thank you very much. Gernot
0
7136
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7412
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.