Once write as UTF-16BE data and convert it to UTF-16LE by using iconv
set aDesktop to path to desktop
set aTDesktop to aDesktop as string
set aTDesktop to aTDesktop as Unicode text
set a to "TEST STRING" as Unicode text
set targetPath to aTDesktop & "outFile.txt"
saveInEncoding(a, targetPath, "UTF-16LE") of me --UFT-16LE
--saveInEncoding(a, targetPath, "SHIFT_JISX0213") of me--Shift JIS
--saveInEncoding(a, targetPath, "EUC-JISX0213") of me --EUC
on saveInEncoding(aText, aPath, aEncoding)
set a to aText as Unicode text
set aTmp to path to temporary items from user domain
set outFile to (aTmp as string) & "temporary_utf16be_text_fromAS.txt"
write_to_file(a, outFile, false) of me
do shell script "sync"
set outPPath to quoted form of POSIX path of (outFile as alias)
set cnvPPath to quoted form of POSIX path of aPath
on write_to_file(this_data, target_file, append_data)
set the target_file to the target_file as text
set the open_target_file to open for access file target_file with
if append_data is false then set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
on error error_message
close access file target_file
On 2009/04/20, at 15:18, Sutapalli Satyanarayana wrote:
I wrote apple script that writes some text to a file in unicode
I know that by default it is in UTF-16 format. But how to confirm
that I am writing in Little Endian only and how to check the output
file whether it is in little endian or not.
My script is as following:
set the_file to (((path to desktop) as string) & "temp.txt") as file
open for access the_file with write permission --Open the file for
writing and move to end of fle
set eof of the_file to 0
write ((ASCII character 254) & (ASCII character 255)) to the_file --
> not as Unicode text
--set writeRecord with some data
write writeRecord to the_file starting at eof as Unicode text
write ((ASCII character 13) & (ASCII character 10)) to the_file as
close access the_file
By default "temp.txt" file will be in Big endian UTF-16 format. I
want it to be in Little endian UTF-16 format.
How can I achieve this task with apple script
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription: