URL Syntax and RevBrowser on Mac

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Simon Knight
Posts: 339
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

URL Syntax and RevBrowser on Mac

Post by Simon Knight » 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

Code: Select all

replace " " with "%20" in tMyFilePath
  replace "|" with "%7C" in tMyFilePath
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:

Code: Select all

20160101 iphone 6s order John Lewis | Your receipt.pdf
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:

Code: Select all

/Users/skids/Desktop/DocumentScans/3rdJan2017Scans/20160101%20iphone%206s%20order%20John%20Lewis%20%7C%20Your%20receipt.pdf
The use of ERLEncode on the same file specification results in a string which causes revBrowser to fail:

Code: Select all

%2FUsers%2Fskids%2FDesktop%2FDocumentScans%2F3rdJan2017Scans%2F20160101+iphone+6s+order+John+Lewis+%7C+Your+receipt.pdf
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
best wishes
Skids

Post Reply

Return to “Mac OS”