Solved

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

Posted on 2003-11-04
6
522 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

828 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