473,799 Members | 3,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Decoding DOS formatted file

Hi all

In my C# program I need to read a file, which is exported from a DOS
program. So words such as "Afløser" (with special danish characters) is
read like "Afl�ser" .

How do I decode/encode DOS formatted strings to the right ".net" format.

Cheers
Bjarne Nielsen
Aug 28 '07 #1
3 2500
On Aug 28, 3:19 pm, Bjarne Nielsen <bniel...@post1 1.tele.dkwrote:
Hi all

In my C# program I need to read a file, which is exported from a DOS
program. So words such as "Afløser" (with special danish characters) is
read like "Afl?ser".

How do I decode/encode DOS formatted strings to the right ".net" format.

Cheers
Bjarne Nielsen
Hi,
try to take a look at the System.Text namespace. It contains classes
for encoding/decoding text
from/to different code pages. You should guess which encoding your
file uses (i.e. unicode, utf8, etc...)
and the uses the appropriate method of the encoding classes.

Ask if you need more help!
Bye.

Aug 28 '07 #2
On Aug 28, 2:19 pm, Bjarne Nielsen <bniel...@post1 1.tele.dkwrote:
In my C# program I need to read a file, which is exported from a DOS
program. So words such as "Afløser" (with special danish characters) is
read like "Afl?ser".

How do I decode/encode DOS formatted strings to the right ".net" format.
Find out which code page your file is in - it may be 437, but it may
not be - different systems used different code pages.

When you know the code page, use Encoding.GetEnc oding(codePage) and
then supply that whatever method you're using to read the file.

Jon

Aug 28 '07 #3
On Tue, 28 Aug 2007 06:43:02 -0700, Jon Skeet [C# MVP] wrote:
On Aug 28, 2:19 pm, Bjarne Nielsen <bniel...@post1 1.tele.dkwrote:
>In my C# program I need to read a file, which is exported from a DOS
program. So words such as "Afløser" (with special danish characters) is
read like "Afl?ser".

How do I decode/encode DOS formatted strings to the right ".net" format.

Find out which code page your file is in - it may be 437, but it may
not be - different systems used different code pages.

When you know the code page, use Encoding.GetEnc oding(codePage) and
then supply that whatever method you're using to read the file.

Jon
Thank you Jon and Ciccone

It took me quite some time to make it work, until I realised, that I needed
two different encodings, one for reading the file, and another for writing
back to the new file (it's a file conversion program).

But with your help and a lot of patience and fooling around, I got it to
work.

Thanks!
Aug 30 '07 #4

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

Similar topics

0
2654
by: ding feng | last post by:
I have got formatted files. All of these file takes this form: obj1 method1 obj2 string1 obj3 string2 argument. Of course, each file can have maximum fields as shown above, or minimun fields like this: obj1 method1. For example, file1 can be like this: 10 obj1 method1
6
1200
by: mesterak | last post by:
I have some log files I need to process via VB.NET and C# based applications. I read the entire contents of each file individually into a string variable using the StreamReader class (.ReadToEnd). I want to split the lines up from each file and add the lines to an an ArrayList (via AddRange), but for some reason I cannot come up with a way to split the lines correctly. Can anyone please provide a method using string conversions or Regex...
5
1925
by: ashishnh33 | last post by:
cud u plz tell me how to find all .obj files in the system using c++ culd u plz tell me the concept plzzzzz.
3
1252
by: John | last post by:
I have a text file that is formatted like this: 123456789 SOLD 1 12/12/2006 Smith 45,525 987654321 SOLD 3 01/01/2006 Jones 23,252
5
6367
by: Peter Jansson | last post by:
Hello group, The following code is an attempt to perform URL-decoding of URL-encoded string. Note that std::istringstream is used within the switch, within the loop. Three main issues have been raised about the code; 1. If characters after '%' do not represent hexademical number, then uninitialized value variable 'hexint' used - this is undefined behavior. 2. This code is very inefficient - to many mallocs/string
1
3217
by: lenniekuah | last post by:
I have written a VB6 program extracting Customers Name and address from a table to incorporate it into a letter and output it to MS WORDS. At the bottom of the letter I tried to insert a digitised signature TIFF formatted file. Instead of the signature appearing on each letter generated by WORDS, all the signatures congregated at the last Letter. Being new to VB6 and just don't know what went wrong Here are sample of the script that insert...
6
13135
by: redcic | last post by:
Hi all, I use the csv module of Python to write a file. My code is of the form : cw = csv.writer(open("out.txt", "wb")) cw.writerow() cw.writerow() And i get an out.txt file looking like:
2
1480
by: ajay0419 | last post by:
Hi: I am trying to read from a file, which stores answers for a particular question(The answers are stop listed ). Each answer in the file is enclosed in opening and closing braces. Here is the sample file { tenets nutrigenomics jim kaput improper diets risk factors disease dietary chemicals alter gene expression andor genome diseases } { individuals nutritional needs a result own genetic } I am trying to read from this file and...
10
1636
by: Jun | last post by:
hello, I've a data file ======== 4 1 1 1 1 5 1 1 1 1 1 2 1 1 ========
0
9685
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
9538
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
10247
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10214
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9067
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...
1
7561
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6803
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
5459
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2935
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.