473,698 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASCII / ANSI encoding

Hi,

I'm in the process if converting the data out of an old DOS-based
SunAccounts system (don't ask!) into SQL Server.

The data has been sent to me as a collection of hundreds of SunAccounts
backup files and it's a simple (yet extremely laborious!) process of opening
each backup file in turn, reading the file line by line, splitting it up
into its constituent parts, and then squirting it into SQL Server.

However, I'm experiencing a problem because Sun, being a DOS-based system,
uses ASCII encoding. Specifically, the old chestnut of the British pound
sign, which Sun considers to be hex 9c (i.e. Alt-156). However, Windows
using ANSI encoding sees this character as o instead of £ (Alt-163).

If I open the files into a StreamReader object without specifying an
encoding, C# appears to be using ASCII encoding. This has the effect of
ignoring the character completely which, in turn, throws the rest of the
import of of kilter because the file format is fixed-width, not delimted.

Therefore, can anyone please tell me what encoding I should use when reading
the file into a StreamReader object? I've tried several, but none appears to
work correctly so far. Some render the character as a question mark or a
blank square which, although not correct, at least doesn't stop the rest of
the import from working...

Any assistance gratefully received.

Mark
Dec 16 '05
10 30166
> "DOS ASCII" and "WINDOWS ASCII" aren't precisely defined terms though.
DOS used lots of different default code pages depending on your region,
and so does Windows.

Joerg is right, there is no "DOS ASCII" and "WINDOWS ASCII", and ASCII is
very precisely defined.

ASCII = everything between 0-127, and is the same in all code pages (except
EBCDIC, but that is not ASCII, is EBCDIC :-)

ANSI code page = the Windows code pages. Same as "system code page". For Win
9x cannot be changed, for W2K, XP and newer it can be changed.
http://www.mihai-nita.net/20050611a.shtml

OEM code page = the DOS code pages. It is still used in Windows for console
applications.

See some info here:
http://blogs.msdn.com/michkap/archiv...08/369197.aspx
http://blogs.msdn.com/oldnewthing/ar...08/389527.aspx
http://www.mihai-nita.net/glossary.shtml

--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Dec 17 '05 #11

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

Similar topics

1
1886
by: duzos duzos | last post by:
i need to connect to a dbf database with ansi/oem encoding the connection is ok but i have problem with page encoding the characters don't display as they should! does anyone have any suggestions?? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
37
10150
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be accidentally entered are properly represented when the document is served. My programming language allows me to get the ascii value for any individual character so what I am doing when a change is saved is to look at each character in the content and...
2
6196
by: Martín Marconcini | last post by:
Hello there, I'm writting (or trying to) a Console Application in C#. I has to be console. I remember back in the old days of Cobol (Unisys), Clipper and even Basic, I used to use a program (its name i cannot recall now...) where I designed the "screen" using this "program" and then saved it into an ASCII file. (thus, using 'extended' ASCII's like Lines, Corners, etc. and making screens look nicer and more professional). Then reading a...
3
3034
by: sjoshi | last post by:
I'm doig a test using XP English with LocalSettings set to Russian. When trying to open an XML file with ANSI encoding, I get errors. When I change the encoding to UTF8, I can read the file successfully. I'm wondering why this happens. Any help is appreciated. thanks Sunit
4
19007
by: Nick | last post by:
Hi, I am trying to output a string of chinese characters as a text file. When I open a file for writing from VB, the file is automatically set to UTF-8 encoding (can tell by opening the file from notepad). However, when I open this file from a Chinese program that does not support unicode, garbage is displayed. So what I have to do is to first use Notepad to change the encoding of the file to ANSI encoding, then the file would be...
4
14306
by: Richard | last post by:
I need to use ANSI encoding in VB.NET, but can't seem to find it, can anyone help, I can only find these ASCII UTF7 UTF8 default BigEndianUnicode Unicode, and a method getEncoding(codepage as integer),
0
8676
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7732
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.