Solved

how to convert Apple mac text file,to a normal windows encoding

Posted on 2003-11-04
6
518 Views
Last Modified: 2007-12-19
hi i want to read a file written on a mac os. could this be done
in c#
0
Comment
Question by:hema_jone_mickey
  • 3
  • 3
6 Comments
 
LVL 15

Expert Comment

by:SRigney
ID: 9681558
If the file is saved in text format then yes it should be possible.

Apple only uses the either the Line Feed or Carriage Return character at the end of each line (not sure which one), while Windows uses Line Feed and Carriage Return, but other than that there shouldn't be a problem.
0
 

Author Comment

by:hema_jone_mickey
ID: 9681676
i used the following code
FileStream ReadPdf = new FileStream("c:\\test.txt", FileMode.Open);
                  long FileSize;
                  FileSize = ReadPdf.Length;
                  byte[] Buffer = new byte[(int)FileSize];
                  ReadPdf.Read(Buffer, 0, (int)ReadPdf.Length);

                  String str = System.Text.Encoding.Default.GetString(Buffer);

                        ReadPdf.Close();

but it's supposed it's Arabic ,it returned arabic words but no understandable

so what is the solution ,and what type to save the file in
and thanks
0
 

Author Comment

by:hema_jone_mickey
ID: 9681680
an dhow to do it  SRigney
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 15

Expert Comment

by:SRigney
ID: 9682605
How did you get the file from the Apple into the Windows operating system?

Ftp is my preferred method.
0
 

Author Comment

by:hema_jone_mickey
ID: 9684730
i don't ask how to get the file ,i ask about the conversion to the readable format by windows .how to convert from C# Code the MAC FORMAT TO THE WINDOWS FORMAT?
0
 
LVL 15

Accepted Solution

by:
SRigney earned 20 total points
ID: 9686567
I know, but there's a difference between reading a MAC file from a Mac formatted floppy disk and getting the file via ftp.

On all MAC files that I have received the file is in ASCII format with the only difference between Windows being the end of the line using a single character instead of 2 characters.

Thus the simple code that you have already posted would work for every MAC file that I have ever received.

There's also an editor on the internet called UltraEdit32  http://www.ultraedit.com/
There is a conversion from UNIX/MAC to DOS that it uses, but again, it deals with replacing the single endline character with the 2  characters.   It will give you an editor that will show you the same thing that you should see in your code.

If the file that you have is not a simple text file, but a formatted file that was formatted by some Mac Editor such as Word then it will have additional formatting information other than simple text.  It's possible that you are just reading the formating information.  If that's the case then you won't be able to work around it within your code without knowing the entire formatting schema of the editor.  At that point the originator of the file will have to save it to a text only format and give you the file again.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now