Re: Interarchy encoding howto?
Re: Interarchy encoding howto?
- Subject: Re: Interarchy encoding howto?
- From: JollyRoger <email@hidden>
- Date: Fri, 02 Mar 2001 11:24:06 -0600
on 3/2/2001 12:04 AM, Jan Jaap Siewers at email@hidden wrote:
>
Nothing wrong with that, except that when I drop files containing slashes in
>
their names things go wrong. Is there a way to encode a string so it can be
>
used as an URL. Like "hello/there" -> "hello2%Fthere".
Actually, that would be "hello/there". The % is an escape character, and
the 2Fis the hex equivalent of the code representing the forward slash
character.
>
When you use the script editor to record a script with interarchy and you
>
drop a file to send it, somehow slashes will be converted on the spot. I
>
just can't figure out how to script it.
If you can't find a robust encoder, you could always change the filename
yourself before uploading:
set oldFilename to "file/name/with/slashes"
set newFilename to MungerString("/", "/", oldFilename)
log newFilename
on MungerString(searchStr, replaceStr, sourceStr)
-- replace <searchStr> with <replaceStr> in <sourceStr>
try
set searchStr to (searchStr as text)
set replaceStr to (replaceStr as text)
set sourceStr to (sourceStr as text)
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to (searchStr)
set theList to (every text item of sourceStr)
set AppleScript's text item delimiters to (replaceStr)
set theString to theList as string
set AppleScript's text item delimiters to oldDelims
return theString
on error errmsg
display dialog "MungerString() failed: " & errmsg
end try
end MungerString
And if you DO find an automated way to encode, please post to the list so
the rest of us can check it out. :)
JR