Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2003-11-04
6
Medium Priority
?
532 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 40 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

927 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