Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem copying file



Daniel Child <email@hidden> wrote:

>During my experiments to handle Asian characters, I tried copying the
>rtf file (created by TextEdit) into a duplicate file. The duplicate
>file appears to be created, but TextEdit cannot open it.

Exactly what did you do to "copy the RTF file"?

I'm assuming you used a Java program to make this copy of the RTF file.

In this Java program, did you use Reader and Writer (which translate
between bytes and chars), or InputStream and OutputStream (which only push
bytes around without translation)?

If you used Reader and Writer, then the default text-encoding, designated
by the "file.encoding" property will affect the outcome. On Mac OS X, that
encoding is "MacRoman". On other platforms it's something else, and the
byte-to-char-to-byte translation of Reader/Writer may have no net effect.

The way to avoid this problem is to use InputStream and OutputStream,
rather than Reader and Writer, avoiding any translations at all.


If you run this Terminal command:
md5 yourOriginalFile.rtf yourDuplicatedFile.rtf

the "checksums", which are 16 bytes of hex, should be identical. If they
aren't, then the problem is definitely attributable to some kind of
data-translation error or other mangling of the original RTF bytes.


>I ran this simple program on UNIX and it ran perfectly. Is there
>something special you need to do when creating files on the Mac? Thanks.

Which Unix did you run it on?

Technically, Mac OS X is a Unix, so I'm guessing you meant some OTHER Unix.

You can print the value of the "file.encoding" system property to see what
the default text-encoding is. I suspect it's something like "8859-1",
"UTF-8", or "Cp1252", but please tell us what you actually get.

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.