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: Converting text



It sounds like you might be writing the text info the file with 16-bit Unicode encoding. In 16 bit Unicode, each character is two bytes as opposed to ASCII in which each character is one byte. For English, most of the frequently used characters have the same value in ASCII and Unicode, except that there is an additional high order byte with a 0 in it. My guess is that the text editor you are opening it in is changing the zeros (which do not represent a legal ASCII character) to spaces. The first thing I would try would be to open the file in a Unicode-aware text editor. If you have BBEdit (on the Mac) it can open it and you can pop up a menu at the top of its document window that will tell you whether the text in Unicode encoded.

I think you can force AppleScript to use 8-bit ASCII encoding with the "as string" coercion.

David

On Oct 16, 2004, at 8:13 PM, John Mistler wrote:

I am writing a text file to disk from my application with the following:

on writeFile(theText, targetFile)
set the targetFile to the tartgetFile as text
set the openTargetFile to open for access file targetFile with write
permission
set eof openTargetFile to 0
write theText to the openTargetFile
close access the openTargetFile
return true
end writeFile


The file writes just fine, but when I copy the text file over to a Windows
(yeah, I know) machine, the text has spaces in between each character and
the carriage returns are wrong. Does anyone know how I can write the text
so that it will transfer to Windows correctly?


Thanks,

John

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/ email@hidden


This email sent to email@hidden


--
David Durkee
email@hidden
<http://ddurkee.homeip.net/>

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden
References: 
 >Converting text (From: John Mistler <email@hidden>)



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.