urlEncode() and ASCII extended characters

30 views
Skip to first unread message

Collection PhotoGraphex

unread,
Jun 25, 2020, 10:45:54 PM6/25/20
to superca...@googlegroups.com
Hello, 

I wonder, if urlEncode() isn't supposed to encode only SPACE character? 

As an example for my question, suppose I am having a valid local network POSIX file path with extended ASCII characters as follow :

put "/Volumes/Catalogues/Numéros/Série CO Cata/CO0501/CO 531 10A c011 6x~.jpg" into TheURL


As a preamble, I should add that all the files I wish to treat are also accessible from the internet. 

The previous valid POSIX file path for instance, after the prefix replacement for HTTP would look like it:

put "catalogue.photographex.com/Numéros/Série CO Cata/CO0501/CO 531 10A c011 6x~.jpg" into TheURL

To get a valid URL, I would use urlEncode(TheURL) for conversion with a script that may looks like it:

put "http://" & urlEncode("catalogue.photographex.com/Numéros/Série CO Cata/CO0501/CO 531 10A c011 6x~.jpg") into TheURL


The returned result is: 

http://catalogue.photographex.com/Numcatalogue.photographex.com/Num√©ros/Scatalogue.photographex.com/Num√©ros/S√©rie%20CO%20Cata/CO0501/CO%20531%2010A%20c011%206x~.jpg”


Which is obviously an incorrect conversion, as the right conversion may looks like this:


http://catalogue.photographex.com/Numéros/Série%20CO%20Cata/CO0501/CO%20531%2010A%20c011%206x~.jpg


What would be the right way to get a valid conversion with s file path with extended ASCII characters?


Thanks for your help and suggestions!


Regards


André

codegreen

unread,
Jun 26, 2020, 12:23:58 AM6/26/20
to SuperCard Discussion

codegreen

unread,
Jun 26, 2020, 12:42:49 AM6/26/20
to SuperCard Discussion
The reason you're getting that gibberish instead is apparently a bug in Apple's Core Foundation framework (the low-level call that creates a CFURL from a raw string of bytes doesn't seem to like at least some high-order MacRoman characters, even if you correctly tell it what encoding they're expressed in). The CFURL it produces looks normal in the debugger, but when explicitly converted to a CFString for output it yields garbage.

I'll send you a fix to confirm it works at your end too...

Thanks,
-Mark 


Collection PhotoGraphex

unread,
Jun 26, 2020, 9:20:41 AM6/26/20
to superca...@googlegroups.com
Hello Mark, 
Yes! It is actually the right way for the full encoding!

I am going to perform further testings on your proposed fix! 

Thank you! 

André

Edward Wall

unread,
Jun 26, 2020, 9:12:31 PM6/26/20
to superca...@googlegroups.com
Is there any way to script the Finder so as to have applescript open a SuperCard project using SuperCard Player? For example.

tell application “Finder” to open (supercard script) using “SuperCard 4.8 Player”

doesn’t seem to work.

Ed Wall





Edward Wall

unread,
Jun 27, 2020, 12:08:45 PM6/27/20
to superca...@googlegroups.com
Answered my own question. With the Standalone maker, I can make a project that SuperCard Player opens:

tell application “Finder” to open (supercard .sp45 built with Standalone maker)

Ed

"In the end, it’s not the years in your life that count. It’s the life in your years.” - Abraham Lincoln

Collection PhotoGraphex

unread,
Jun 27, 2020, 10:03:45 PM6/27/20
to SuperCard Discussion
Hello Mark, 
 
I'll send you a fix to confirm it works at your end too...

According to all the examples I've tried so far, it just works very, very well!

I suppose, this fix will be part of the next release? 

Or is there a way to import this new function into an actual SuperCard application?

Regards

André 
Reply all
Reply to author
Forward
0 new messages