• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)


  • Subject: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
  • From: Michael Terry <email@hidden>
  • Date: Thu, 20 Nov 2003 12:55:51 -0800

Hello,

Has anyone ever noticed that you can't compile data codes with 'run script' if the number of characters in the string is too big? And too big isn't even all that big. I can't compile

set d to "+data data0000;"
run script d

if I add enough zeros to make 'd' longer than 266 characters. "Way too long, dude." I've wondered if that's one of Jon Pugh's...

Anyway, the reason I ask is because I was trying to write some data to file, and it would go a lot faster if I didn't have to keep stopping every so often to compile tiny little chunks of data. 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?


property _hexChars : "0123456789ABCDEF"

-- ------------------------------------------------------------------------ --------
-- return hex unicode codepoints split up into a list of chunks
-- encoded in AS raw data codes
-- ------------------------------------------------------------------------ --------
on hexCodepoints()
set compilableBlock to ""
set codepoints to {}
repeat with i from 1 to 16
repeat with j from 1 to 16
repeat with k from 1 to 16
repeat with l from 1 to 16
tell my _hexChars
set compilableBlock to compilableBlock & its item i & its item j & its item k & its item l
end tell
end repeat
set the end of codepoints to run script "+data data" & compilableBlock & ";"
set compilableBlock to ""
end repeat
end repeat
end repeat
return codepoints
end hexCodepoints

property _encodingMarker : run script "+data dataFEFF;"

set startTime to current date
set fileRef to file specification (((path to temporary items) as Unicode text) & "Unicode Table.txt")
open for access fileRef with write permission
write _encodingMarker to fileRef
repeat with i in hexCodepoints()
write i to fileRef
end repeat
close access fileRef
tell application "Finder" to open (path to temporary items)
(current date) - startTime
-- ~90 sec


Mike
_______________________________________________
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.

  • Follow-Ups:
    • Re: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
      • From: BJ Terry <email@hidden>
    • Re: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
      • From: Walter Ian Kaye <email@hidden>
  • Prev by Date: Re: (no subject)
  • Next by Date: Re: Frustrated novice wants to paste the clipboard
  • Previous by thread: Re: (no subject)
  • Next by thread: Re: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
  • Index(es):
    • Date
    • Thread