| 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
.
|
|
|
|

|
Related Articles |
|
|