Question about Extended ASCII character set, and fstream



 DEVELOP > c-Plus-Plus > Question about Extended ASCII character set, and fstream

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: ""
Date: 20 Oct 2004 11:55:27 PM
Object: 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/default.asp?url=/library/en-us/dllproc/base/char_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
.

User: "Catalin Pitis"

Title: Re: Question about Extended ASCII character set, and fstream 21 Oct 2004 04:30:49 AM
<nospam@all.com> wrote in message news:lqSdnTWrgfWi3OrcRVn-jA@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/default.asp?url=/library/en-us/dllproc/base/char_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
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER