467,923 Members | 1,372 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,923 developers. It's quick & easy.

Question about Extended ASCII character set, and fstream

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 extended ascii (codes 0 to 255). I am using ofstream to output, and this is the line doing the actual output:

outfile << screenbuffer[i].Char.AsciiChar;

Note that screenbuffer is an array of type 'CHAR_INFO', quick info of it here:

http://msdn.microsoft.com/library/de...r_info_str.asp

Anyhow, the output, when I open it up in Notepad, shows ASCII characters fine, but nothing from the extended set (the extened set characters are garbled... into other characters.) When I put some extended ASCII chars into notepad (by holding ALT and pressing some numbers), they appear ok. When I try to save the file, it tells me I need to save in Unicode format.

SOOOO, I cannot figure out how to output to a text file in Unicode format from my program. Any ideas?
Thanks in advance!
Andy
Jul 22 '05 #1
  • viewed: 3332
Share:
1 Reply

<no****@all.com> wrote in message news:lq********************@comcast.com...
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 extended ascii (codes 0 to 255). I am
using ofstream to output, and this is the line doing the actual output:

outfile << screenbuffer[i].Char.AsciiChar;

Note that screenbuffer is an array of type 'CHAR_INFO', quick info of it
here:

http://msdn.microsoft.com/library/de...r_info_str.asp

Anyhow, the output, when I open it up in Notepad, shows ASCII characters
fine, but nothing from the extended set (the extened set characters are
garbled... into other characters.) When I put some extended ASCII chars
into notepad (by holding ALT and pressing some numbers), they appear ok.
When I try to save the file, it tells me I need to save in Unicode format.

SOOOO, I cannot figure out how to output to a text file in Unicode format
from my program. Any ideas?

You have two choices:

1. Use wide char streams (std::wofstream)

or

2. Use unformatted output (basic_ostream<...>::write method)

Br/
Catalin
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by bgbauer70 | last post: by
1 post views Thread by Bülent Üstün | last post: by
6 posts views Thread by KA Kueh | last post: by
3 posts views Thread by Youssef Mesri | last post: by
4 posts views Thread by =?Utf-8?B?Um9zaGFuIFIuRA==?= | last post: by
6 posts views Thread by Andy Leese | last post: by
13 posts views Thread by ramif | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.