Unwanted null characters
Unwanted null characters
- Subject: Unwanted null characters
- From: Joe <email@hidden>
- Date: Thu, 4 Oct 2007 11:22:05 -0700
Recently, Michelle posted a fragment for getting Safari's selected
text. Based on that, I wrote a script to put Safari's selected text
into a text file for further use. Unfortunately, while the output
looks fine, there appears to be a null character between every
character in the file written by the script.
<MY SCRIPT>
tell application "Safari"
set selectedText to do JavaScript "unescape(getSelection())" in
document 1
set theurl to get URL of document 1
end tell
set currentDate to (current date) as text
set clipFile to (path to desktop folder as text) & "SafariText.txt"
try
close access file clipFile
end try
set myFileRef to open for access file clipFile with write permission
write (currentDate & return & theurl & return & "-------------------"
& return & selectedText & return &
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & ¬
return & return) to myFileRef starting at eof
close access myFileRef
<END>
I accidentally discovered the presence of the nulls when I tried
pasting a URL from the text file into a browser - It failed.
I can open the file, select a bit of text and drag it onto the
desktop as a clipping file. The file name of the clipping reveals
part of the problem.
Example clipping name:
h-t-t-p---/-/-w-w-w-.-b-o-s- 1
The original text (and I don't know if this will send correctly) was
this:
h t t p : / / w w w . b o s t o n . c o m / n e w s / g l o b e /
But while that shows up with spaces between each character here in
Mail, it does not when viewed in TextEdit (where it looks correct).
My question is how can I remove null characters with AppleScript
before writing to file?
Thanks
Joe
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden