Converting textfile from Mac to Windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jone

    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!


  • Peter Duniho

    #2
    Re: Converting textfile from Mac to Windows

    On Wed, 18 Jun 2008 11:21:30 -0700, Jone <jone@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

    Comment

    • Joachim Van den Bogaert

      #3
      Re: Converting textfile from Mac to Windows

      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



      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

      Comment

      • Jone

        #4
        Re: Converting textfile from Mac to Windows


        "Joachim Van den Bogaert" <joachim@yamaga ta-europe.comwrote in message
        news:c8cd4d70-58bb-4671-a3ba-834c907352eb@f3 6g2000hsa.googl egroups.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
        >

        >
        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


        Comment

        Working...