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



If you inserted an ASCII character 10 and/or 13 right at the beginning that
would be coercing the text that follows to string. In Panther. It won't in
Tiger. So I strongly you advise you to take David's suggestion and simply
convert the final text (after you've inserted all the extra LFs which you
also need) 'as string'. That's not really so difficult, is it?

-- 
Paul Berkowitz


> From: John Mistler <email@hidden>
> Date: Sat, 16 Oct 2004 21:54:02 -0700
> To: <email@hidden>
> Subject: Re: Converting text
> 
> Thanks for the advice.  I thought it was going to be something complicated
> like this, but it ended up that windows requires the end of a line to be
> (ASCII character 13)&(ASCII character 10) -- not just (ASCII character 13).
> So, I tried adding an (ASCII character 10) at the end of each line and, for
> some reason, the spaces in between each character went away.  Not sure why,
> but now it works.  Thanks again,
> 
> John
> 
> on 10/16/04 9:34 PM, David Durkee at email@hidden wrote:
> 
>> 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/johnmistler%40adelp>>
h
>> ia.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
> b.edu
> 
> This email sent to email@hidden


 _______________________________________________
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: 
 >Re: 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.