Applescript Studio writes "\x00" between EVERY CHARACTER on file

Hi all!

I am building an xml file and writing it out…

I have the following:


set txt_var to "<DAZzle Start=\"PRINTING\" Prompt=\"NO\" OutputFile=\"/" & order_id & "-OUT.xml\" Test=\"YES\" SkipUnverified=\"YES\">
<Package ID=\"1\">
    <MailClass>" & mailclass & "</MailClass>
    <FlatRate>" & flatrate & "</FlatRate>
    <DateAdvance>1" & dateadvance & "/DateAdvance>
    <WeightOz>" & weight & "</WeightOz>
    <TotalPostage/>
    <Stealth>TRUE</Stealth>
    <Services DeliveryConfirmation=\"" & deliveryconfirmation & "\" InsuredMail=\"" & insured_mail & "\"></Services>
    <Value>" & theValue & "</Value>
    <Description>" & theDescription & "</Description>
    <ToName>" & contents of data cell "recipient_name" of j & "</ToName>
    <ToCompany></ToCompany>
    <ToAddress1>" & contents of data cell "ship_address_1" of j & "</ToAddress1>
    <ToAddress2>" & contents of data cell "ship_address_2" of j & "</ToAddress2>
    <ToCity>" & contents of data cell "ship_city" of j & "</ToCity>
    <ToState>" & contents of data cell "ship_state" of j & "</ToState>
    <ToPostalCode>" & contents of data cell "ship_zip" of j & "</ToPostalCode>
</Package>
</DAZzle>

"
					set filen to order_id & "-IN.xml" as string
					set fileRef to (open for access file filen with write permission)
					set eof of fileRef to 0
					write txt_var to fileRef
					close access fileRef

The problem is that when it runs, and I open it in BBEdit, it shows upside down question marks in front of EVERY letter including the spaces.

i copied the character and BBEdit shows it as \x00

How do i get rid of this PLEASE

thx

Jann

DUH

Added

as string

at end of

set txt_var

assignment

worked.

Wonder why?

Yes. The new behaviour of “write” is not writing “as text” (or “as string”), as previously, but guessing the “class” of the provided data. So, as you were providing Unicode text, it was writing automatically “as Unicode text”.