473,624 Members | 2,269 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 5389
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.c omwrote:
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
2924
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 in Nederlands, maar Engels is ook goed. Thnx, Rensjuh
37
10142
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 accidentally entered are properly represented when the document is served. My programming language allows me to get the ascii value for any individual character so what I am doing when a change is saved is to look at each character in the content and...
5
3612
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 string will be 120 char length, and incase the string is less then 120 chars, i need to fill it with spaces till it will be 120 chars length, is there a better way then:
61
4917
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: <= >= != this should improve readibility (and make language more accessible to beginners).
15
2307
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 one very large DLL that has the bulk of the code. I've downloaded the MFCWinFormsSample.EXE and have noticed that the main app could stay as a native executable (i.e. no CLR support) whereas the various ..DLLs can be marked as having CLR...
3
6044
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 is I never know in advance what size the string will be. When I call Encoding.ASCII.GetString I need to specify the size. If I set it to ret.Length as above then in the debugger I can see msg is the full 1024 bytes (0 padded at the end...
8
8831
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
12784
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 to python-3000@python.org In summary, this PEP proposes to allow non-ASCII letters as identifiers in Python. If the PEP is accepted, the following identifiers would also become valid as class, function, or variable names: Löffelstiel,...
4
2624
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
8233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8170
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8675
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8619
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8334
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8474
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7158
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6108
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.