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 23:12:26 +0000
In my previous message of Saturday, 22 November 2003, I wrote:
>
on getAsciiChars()
[snip]
>
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)
Nearly three times as fast as even that is:
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
end getAsciiChars
property asciiChars : getAsciiChars()
property _encodingMarker : (ASCII character 254) & (ASCII character 255)
set t to (current date)
set astid to AppleScript's text item delimiters
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 16
set hi to my asciiChars's item (i div 256 + 1)
set AppleScript's text item delimiters to hi
get hi & my asciiChars's items (i mod 256 + 1) thru (i mod 256 + 16)
write result to fileRef
end repeat
on error msg
display dialog msg
end try
close access fileRef
set AppleScript's text item delimiters to astid
((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.