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 10 30123
hi Mark,
i've gone through such pain but my problem was little different. well
dude i would say you can not use StreamReader in your case. you have to
use BinaryReader to read whole file and than should use
"System.Text.AS CIIEncoding" to retrive the data into the WINDOWS ASCII
format.
this should work.
Mark Rae wrote: 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).
ASCII is a 7-bit character system, and does not define any character
code higher than 127 (hex 7F). A quick poke at Google suggests that 9C
is the pound sign in Microsoft's DOS codepage 437. Hmm, or maybe 850.
Take a look at <http://en.wikipedia.or g/wiki/Category:DOS_co de_pages>
and links therefrom to decide for yourself.
However, Windows using ANSI encoding sees this character as o instead of £ (Alt-163).
I'm really no expert on these matters, but I'm fairly sure that
'Windows using ANSI encoding' isn't specific enough to be amgibuous. 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?
If I'm right about the original encoding being DOS codepage 437, you
should use the Encoding created by
System.Text.Enc oding.GetEncodi ng(437). Or try 850.
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.
Encodings are a nightmare. Best of luck!
--
Larry Lard
Replies to group please
"Larry Lard" <la*******@hotm ail.com> wrote in message
news:11******** ************@g4 9g2000cwa.googl egroups.com...
Hi Larry, System.Text.En coding.GetEncod ing(437)
Worked perfectly! Thanks very much.
Mark
<tu************ @gmail.com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com... you can not use StreamReader in your case
Larry Lard's suggestion of System.Text.Enc oding.GetEncodi ng(437) worked
perfectly.
Mark Rae <ma**@markN-O-S-P-A-M.co.uk> wrote: 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).
Neither of those are ASCII characters. ASCII is 7-bit. See http://www.pobox.com/~skeet/csharp/unicode.html for more information.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
<tu************ @gmail.com> wrote: i've gone through such pain but my problem was little different. well dude i would say you can not use StreamReader in your case. you have to use BinaryReader to read whole file and than should use "System.Text.AS CIIEncoding" to retrive the data into the WINDOWS ASCII format.
There's nothing wrong with using StreamReader here, but what's required
*isn't* ASCII. There's no such thing as "Windows ASCII" - there are
various 8-bit "extensions " to ASCII, in various "code pages"; they
aren't ASCII themselves, however.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
what i mean by WINDOWS ASCII is windows compatiable string. that what
was your problem right? you were not able to get DOS ASCII stirng
exactly in WINDOWS string. am i right?
Lucky wrote: what i mean by WINDOWS ASCII is windows compatiable string. that what was your problem right? you were not able to get DOS ASCII stirng exactly in WINDOWS string. am i right?
As Jon said, there's no Windows ASCII, nor a DOS ASCII. There's only
ASCII. There's also no such thing as a Windows compatible string. It's
all just a matter of using the correct encoding.
Cheers,
-- http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e
Lucky <tu************ @gmail.com> wrote: what i mean by WINDOWS ASCII is windows compatiable string. that what was your problem right? you were not able to get DOS ASCII stirng exactly in WINDOWS string. am i right?
"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.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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!
|
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...
|
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'...
|
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
|
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...
| |
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),
|
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...
|
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. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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...
|
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...
| |
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
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...
| |