Re: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
Re: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
- Subject: Re: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
- From: Nigel Garvey <email@hidden>
- Date: Sat, 22 Nov 2003 18:06:25 +0000
Michael Terry wrote on Thu, 20 Nov 2003 12:55:51 -0800:
>
Unfortunately, I
>
can't see any way to write binary data to a file other than assembling
>
it via 'run script' first. Are there other options? If you wanted to
>
write out a list of unicode characters, how would you do it?
on getAsciiChars()
script o
property p : {}
end script
repeat with i from 0 to 255
set end of o's p to ASCII character i
end repeat
return o's p as string
end getAsciiChars
property asciiChars : getAsciiChars()
property _encodingMarker : (ASCII character 254) & (ASCII character 255)
set t to (current date)
set filePath to (path to temporary items as Unicode text) & "Unicode
Table.txt"
set fileRef to (open for access file filePath with write permission)
try
set eof fileRef to 0
write _encodingMarker to fileRef
repeat with i from 0 to 65535 by 8
tell asciiChars
set hi to character (i div 256 + 1)
set lo_idx to (i mod 256 + 1)
get hi & character lo_idx & hi & character (lo_idx + 1) & ,
hi & character (lo_idx + 2) & hi & character (lo_idx + 3) & ,
hi & character (lo_idx + 4) & hi & character (lo_idx + 5) & ,
hi & character (lo_idx + 6) & hi & character (lo_idx + 7)
end tell
write result to fileRef
end repeat
on error msg
display dialog msg
end try
close access fileRef
((current date) - t)
NG
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.