Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2007

Tip: Looking for answers? Try searching our database.

Decoding DOS formatted file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bjarne Nielsen - 28 Aug 2007 14:19 GMT
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
ciccone1978@gmail.com - 28 Aug 2007 14:38 GMT
> Hi all
>
[quoted text clipped - 6 lines]
> 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.
Jon Skeet [C# MVP] - 28 Aug 2007 14:43 GMT
> 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.GetEncoding(codePage) and
then supply that whatever method you're using to read the file.

Jon
Bjarne Nielsen - 30 Aug 2007 09:46 GMT
>> 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
[quoted text clipped - 9 lines]
>
> 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!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.