473,587 Members | 2,230 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting textfile from Mac to Windows

Hello,

I have tried to convert a Mac text file to Windows using code below.

Encoding Win = Encoding.GetEnc oding("Windows-1252");

Encoding Mac = Encoding.GetEnc oding("macintos h");

byte[] macBytes = Mac.GetBytes(Ro w);

byte[] WinBytes = Encoding.Conver t(Mac, Win, macBytes);

char[] WinChars = new char[Win.GetCharCoun t(WinBytes, 0, WinBytes.Length )];

Win.GetChars(Wi nBytes, 0, WinBytes.Length , WinChars, 0);

string WinString = new string(WinChars );

return WinString;

But, it does not convert e.g. German and Scandinavian characters written in
Mac to proper format in Windows.
How can a textfile written in MAc could be converted into Windows
environment?

Cheers!
Jun 27 '08 #1
3 3593
On Wed, 18 Jun 2008 11:21:30 -0700, Jone <jo**@mail.comw rote:
[...]
But, it does not convert e.g. German and Scandinavian characters written
in
Mac to proper format in Windows.
How can a textfile written in MAc could be converted into Windows
environment?
It all depends on what encoding the text _really_ is in.

The encodings you've selected are in fact Mac and Windows encodings. But
just because a file came from the Mac doesn't mean it's using "code page
10000", and likewise just because you're running Windows, that doesn't
mean you want the text encoded in "code page 1252".

So you need to find out where the file came from and what encoding was
actually used. You also need to look at what program you intend to use to
look at the text in Windows and find out what encoding(s) it
expects/supports. Then you need to use the correct source and destination
encodings, based on that information.

Ideally you'll find that on the Mac, you can output your text as a Unicode
format (e.g. UTF-8) and on Windows you can import your text as the same
Unicode format. Then you have no conversion to do at all (well, except
for adding the extra CR to the LF that the Mac text files usually use
alone for line breaks :) ).

Pete
Jun 27 '08 #2
I have experienced the problem of converting windows to mac.
We needed Word files for Mac 8.5 so what I did was the following:
First convert the text to rtf, then parse the rtf with a matrix I
composed from the official codepages you find here

http://unicode.org/Public/MAPPINGS/VENDORS/APPLE/

I used this approach because there was something wrong with the
conversion in Word for Windows.
CE languages showed corrupted characters.

After I wrote the conversion tool, the files were ok for mac.

The text is plain ASCII so I suggest you have a look at the codepages
on the link I gave you
and do a hex dump of your file (rename it to a .bin file for example)
in Visual Studio so you can trace wrong characters.
Maybe then you can find out which code page has been used. If the
approach with the .NET codepages doesnt work
you can still use the matrix method,

Hope this helps,
Joachim

Jun 27 '08 #3

"Joachim Van den Bogaert" <jo*****@yamaga ta-europe.comwrote in message
news:c8******** *************** ***********@f36 g2000hsa.google groups.com...
>I have experienced the problem of converting windows to mac.
We needed Word files for Mac 8.5 so what I did was the following:
First convert the text to rtf, then parse the rtf with a matrix I
composed from the official codepages you find here

http://unicode.org/Public/MAPPINGS/VENDORS/APPLE/

I used this approach because there was something wrong with the
conversion in Word for Windows.
CE languages showed corrupted characters.

After I wrote the conversion tool, the files were ok for mac.

The text is plain ASCII so I suggest you have a look at the codepages
on the link I gave you
and do a hex dump of your file (rename it to a .bin file for example)
in Visual Studio so you can trace wrong characters.
Maybe then you can find out which code page has been used. If the
approach with the .NET codepages doesnt work
you can still use the matrix method,

Hope this helps,
Joachim
Thank Joachim for your reply.
My case is following:

1. Filemaker should write a file to filesystem containig data from database.
2. C# / Asp.Net should read this file, parse it and insert data into SQL
Server.

Problem is that special characters that Filemaker writes into file are not
shown correctly in
Windows.

I have tried to encoding using C#'s Encoding classes but still special
characters are not shown.

Do you know that what is the default encoding when FileMaker writes data
into file?
Is it possible and how to change encoding so that Windows can also
understand it, maybe UTF8?

I would be very grateful for tips what comes to proper encoding between Mac
FileMaker and Windows.

Thanks,

- J
Jun 27 '08 #4

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

Similar topics

7
4998
by: Hans A | last post by:
I have a textfile "textfile.txt" containing a list of words. There is one word on each line. I want to pick two random lines from this textfile, and I have tried to do something like: //Loading the file into an array: $textarray = file("textfile.txt); //Using array_rand to pick two random words $rand_numbers = array_rand($textarray, 2);
1
2529
by: Larry Rekow | last post by:
I have a report that's created each day as a flat textfile. Because I came from the Access world, I created a macro that imports it with a schema that gives meaningful names to the various columns, and then uses a query to massage some of the data for me (deletes the first blank row and does a couple of calculations) Then I use DTS to...
5
2470
by: @ndy | last post by:
I've created a textfile (log) with errors in vba and know i want to print it but i don't know how! Does anywhone have experience with this?
1
3124
by: Michael Schindler | last post by:
Ich habe es nun erreicht, ein textfile einzulesen das nun zeile für zeile im datagrid angezeigt wird. Nun wäre es toll wenn ich das textfile zum beispiel nach jedem blank in eine spalte zerstückeln könnte und meine frage hier wie geht sowas? Ich habe nun das ganze mit folgendem code im datagrid, nur zu welchem zeitpunkt zerstückle ich das...
4
1532
by: Kevin Johnson | last post by:
Hi Using C# and a textfile I need to do two things: 1. Read the contents of the textfile and return the number of words contained in it. 2. Output a list of unqiue words (i.e. not duplicated) to a new textfile. These words should appear on a new line. eg. hello
5
2862
by: db1145 | last post by:
Hello, I am trying to convert a textfile made up of strings of numbers separated by spaces, into a 2D array of the (floating point) numbers themselves. For example the textfile would contain the following: 5 -2 3.3 6 2 1 0 86 9 -3 4 5.8 converted into a float array with dimensions .
1
1806
by: kachokaratz | last post by:
well i have a problem in my project..since the contents of my textfile is too long, i was wondering how to output the textfile in such a way that you can divide the contents to be able to output everything in an organized manner.. my problem is that since my textfile is too long, when i run the program, the output omits the first parts of the...
14
3307
by: blumen | last post by:
Hi all, I'm a newbie in VB.Net Programming.. Hope that some of you can help me to solve this.. I'm working out to read,parse and save textfile into SQL Server. The textfile contains thousands of rows with about 50 coloums every row.. Everythings goes well until I found one textfile with some strange character...seems to be Japanese...
1
2807
by: asedt | last post by:
With my Excel macro and two text files I want to create a new textfile containing the first textfile then text from the sheet and then the second textfile. My problem is that i don't know how to append the second textfile. Sub mysub() Dim TempString As String 'Open the first file Dim fileA As Integer
0
7915
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...
0
7843
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...
1
7967
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...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6619
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...
1
5712
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...
0
5392
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...
1
2347
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1185
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...

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.