URL Syntax and RevBrowser on Mac
Posted: Fri Jan 20, 2017 4:37 pm
Hi,
I have a utility application that displays PDF files in a revbrowser window. The name of the file is passed to the browser as a URL. If the name passed contains either a space or a pipe then the browser fails to locate the file and displays a blank page. The solution is to replace the special characters with their hex values using the lines below
There may be other characters that may be used in Finder file names that will also cause a fail.
I had a look in the dictionary and read about the URLEncode command. This appears to remove the need for a list of special characters but unfortunately it does not seem to work. The example filename contains spaces and the pipe character:
My code prepends the folder path and then use the two replace statements above which result is a string that revBrowser is able to use to display the file:
The use of ERLEncode on the same file specification results in a string which causes revBrowser to fail:
I am surprised that RevBrowser fails to locate the file when it's name has been encoded with URLEncode but this is probably down to my lack of understanding of the URL syntax. Is anyone able to explain what is going wrong.
Thanks
SimonK
I have a utility application that displays PDF files in a revbrowser window. The name of the file is passed to the browser as a URL. If the name passed contains either a space or a pipe then the browser fails to locate the file and displays a blank page. The solution is to replace the special characters with their hex values using the lines below
Code: Select all
replace " " with "%20" in tMyFilePath
replace "|" with "%7C" in tMyFilePath
I had a look in the dictionary and read about the URLEncode command. This appears to remove the need for a list of special characters but unfortunately it does not seem to work. The example filename contains spaces and the pipe character:
Code: Select all
20160101 iphone 6s order John Lewis | Your receipt.pdf
Code: Select all
/Users/skids/Desktop/DocumentScans/3rdJan2017Scans/20160101%20iphone%206s%20order%20John%20Lewis%20%7C%20Your%20receipt.pdf
Code: Select all
%2FUsers%2Fskids%2FDesktop%2FDocumentScans%2F3rdJan2017Scans%2F20160101+iphone+6s+order+John+Lewis+%7C+Your+receipt.pdf
Thanks
SimonK