473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 5380
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
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,...

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.