473,583 Members | 2,875 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
1 3763

<no****@all.com > wrote in message news:lq******** ************@co mcast.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
7759
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 Firefox. Take the following code for example. It WILL stop me from entering zero into the first text box, but it wont stop me from entering...
1
2117
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 kept in a string. What should i convert its encoding to? If you have any idea to solve this, please reply. Thanks
6
2226
by: KA Kueh | last post by:
Dear all, I have a requirement to replace the ' character with ASCII character (146) in C# but it seems that when I do the following the conversion is lost. char t = Convert.ToChar(146); string s = t.ToString(); The trouble now is that the s object now contains the ASCII character (63) now. I know because when I store the string to...
3
24494
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 for decrypting the file works fine however when I encrypt the file, several characters are corrupted. when I looked into it they are always extended...
3
2509
by: Youssef Mesri | last post by:
I have two files, the first one is an ascii file and the second is a binary one. I want to add the ascii file on the end of the binary file in order to obtain a one binary file: I have done something like this but doesn't work: int main(int argc, char **argv) { double c;
4
7220
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 in voice record mode sends the audio (PCM) data on the serial port, few of the characters from these are in Extended ASCII range i.e. more than 127...
6
5389
by: Andy Leese | last post by:
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
1
2670
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 them with CDATA. I can not ignore the use of CDATA as for characters "<" and "&" i need to use it. I am not getting why it is not recognizing the...
13
48050
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 of a symbol printf("Character with an ascii code of 177: %c \n", chr); //tries to print an ASCII symbol...
0
7888
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...
0
7811
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...
1
7922
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...
0
8185
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...
1
5689
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...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1416
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.