473,327 Members | 2,025 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,327 software developers and data experts.

Extended ASCII characters in console app

Hi all,
I need to print the extended character set, the corners,
vertical bars, crossing bars , etc in a console app.

I can fudge it with

#define topT char( 194 ) ;

then,
cout topT ;

but,
Each output item must be followed by a ; . Is there
another way. I have looked through 3 texts and come up
blank on google.

Any help appreciated. Where to look or perhaps what
exactly to search on very welcome.

Thanks

Bob
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 19 '05 #1
4 15861
Bob Hartung wrote:
Hi all,
I need to print the extended character set, the corners,
vertical bars, crossing bars , etc in a console app.

I can fudge it with

#define topT char( 194 ) ;

then,
cout topT ;

but,
Each output item must be followed by a ; . Is there
another way. I have looked through 3 texts and come up
blank on google.

Any help appreciated. Where to look or perhaps what
exactly to search on very welcome.

Thanks

Bob


Any character (not wide characters) can be printed using
the "\xYY" notation, where YY is the hexadecimal notation
of the value.
So your example becomes:
#include <iostream>
using std::cout;
int main(void)
{
cout << "\xC2";
return 0;
}

You can also embed them in regular text:
char some_text[] = "What is this '\xC2'?\n";

If you want to output numbers as characters, then you
should cast the value before outputting:
cout << static_cast<char>(194);
The cast tells the compiler that the value is a character
not an integer.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 19 '05 #2

"Bob Hartung" <rw****@netexpress.net> wrote in message
news:bo********@library2.airnews.net...
Hi all,
I need to print the extended character set, the corners,
vertical bars, crossing bars , etc in a console app.

I can fudge it with

#define topT char( 194 ) ;
It's not a good idea to end your macros with a semicolon.

then,
cout topT ;

but,
Each output item must be followed by a ;
The semicolon is a statement terminator. Use it after
every statement. Do not include it in a macro definition.
. Is there
another way. I have looked through 3 texts and come up
blank on google.


#define whatsit 194
/* etc */
cout << whatsit;

Actually, I'd prefer to use an actual object instead of a macro:

const unsigned char whatsit(194);

/* etc */

cout << whatsit;

-Mike
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 19 '05 #3

Bob Hartung <rw****@netexpress.net> wrote in article
<bo********@library2.airnews.net>...
I need to print the extended character set, the corners,
vertical bars, crossing bars , etc in a console app. ..... Each output item must be followed by a ; . Is there

Perhaps create a for loop with an integer with values (from say, 128) to
255.

A simple C++ cast can convert that integer to a printable char.

(I'm showing this step for clarity)
char c = static_cast<char>(i)

Output this char and the char ';' using cout.

after the loop is done,
cout << endl;
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 19 '05 #4
Bob Hartung wrote:
Hi all,
I need to print the extended character set, the corners,
vertical bars, crossing bars , etc in a console app.

I can fudge it with

#define topT char( 194 ) ;

then,
cout topT ;

but,
Each output item must be followed by a ; . Is there
another way. I have looked through 3 texts and come up
blank on google.

Any help appreciated. Where to look or perhaps what
exactly to search on very welcome.

Thanks

Bob


Hmm, I thought I already answered this.
Short and succinct:
1. cout << '\xC2'; // 0xC2 == 194
2. cout << static_cast<char>(194);
3. const char BAR_CHAR = 194;
cout << BAR_CHAR;
4. #define BAR_CHAR '\xC2'
cout << BAR_CHAR; // Equivalent to #1 above.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 19 '05 #5

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

Similar topics

1
by: | last post by:
Hey all, Quick question...been bugging me for some time, really. I have a console app, it does some things, and I want to save an array of text to a text file. The text consists of ASCII and...
13
by: bgbauer70 | last post by:
My appologies if this ends up being a duplicate post. For some reason the first post never showed up. I've tried about 300 iterrations of this same ability, and none of them seem to work in...
4
by: wob | last post by:
Many thanks for those who responded to my question of "putting greek char into C string". In searching for an solution, I noticed that there are more than one version of "Extended ASCII...
1
by: Bülent Üstün | last post by:
Hi, im trying to upload somefiles using sockets to a FTP site. But i've some problems with extended ascii characters. When i try "MKD bülent" the created folder is "blent". The directory name is...
3
by: JSM | last post by:
Hi, I am just trying to port an existing simple encryption routine to C#. this routine simply adds/substracts 10 ascii characters to each character in a text file (except quotes). The routine...
4
by: =?Utf-8?B?Um9zaGFuIFIuRA==?= | last post by:
Hi All, I am new to C# programming; I am developing an application for recording audio data using voice modem. I am using HyperTerminal to manually process audio data. The modem when configured...
1
by: s123 | last post by:
Hi, while invoking a web service, if in xml request message i wrap the extended ASCII characters with CDATA it is not returning the desired result, while this is not the case if i do not wrap...
13
by: ramif | last post by:
Is there a way to print extended ASCII in C?? I tried to code something, but it only displays strange symbols. here is my code: main() { char chr = 177; //stores the extended ASCII...
0
by: jumperbl | last post by:
I am converting hex to ASCII and one of the words has a dot in the middle, which is in the extended ascii characters. when i do this i get the ascii chars. ...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.