• 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
Re: 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]

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: kai <email@hidden>
  • Date: Sat, 22 Nov 2003 22:19:45 +0000

on Sat, 22 Nov 2003 18:06:25 +0000, Nigel Garvey wrote:

> 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)

Drat!

Actually, that's very, very nifty, Nigel. :-)

But "drat!" anyway - since I'd just come up with the following, and you beat
me to it (both in terms of posting *and* of performance):

--------

script s
set s to ""
repeat with n from 0 to 255
set s to s & (ASCII character n)
end repeat
s
end script

property p : run script s
property m : (ASCII character 254) & (ASCII character 255)
property f : file specification ((path to temporary items as Unicode text) &
"Unicode Table.txt")

set d to current date
set o to open for access f with write permission
set eof o to 0
write m to o
repeat with t in p
set v to ""
repeat with u in p
set v to v & t & u
end repeat
write v to o
end repeat
close access o
(current date) - d

--------

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

  • Prev by Date: Re: (beep) as string
  • Next by Date: Re: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
  • Previous by thread: Re: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
  • Next by thread: Re: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
  • Index(es):
    • Date
    • Thread