Solved

Foxpro function to convert encoded url

Posted on 2011-02-22
2
1,265 Views
Last Modified: 2012-08-14
Does anyone know of a foxpro functon to convert an encoded url to standard form

for example:

http://www.mysite.com/<font-color=red><b>mytext-2010</b></font>/mytext-p-1473.html?name=Chocolate%20Lover%27s%20Special%20%28USA%29

and convet all the hex character like '%20' to the characters that they represent?

0
Comment
Question by:esak2000
2 Comments
 
LVL 41

Accepted Solution

by:
pcelba earned 400 total points
ID: 34951192
This function is relatively easy:

lcX = "http://www.mysite.com/&lt;font-color=red&gt;&lt;b&gt;mytext-2010&lt;/b&gt;&lt;/font&gt;/mytext-p-1473.html?name=Chocolate%20Lover%27s%20Special%20%28USA%29"

? URL2TXT(lcX)

FUNCTION URL2TXT
LPARAMETERS lcURL

LOCAL lcResult
lcResult = lcURL

DO WHILE "%" $ lcResult
  lcResult = STUFF(lcResult, AT("%", lcResult), 3, HEX2TXT(SUBSTR(lcResult, AT("%", lcResult)+1, 2)))
ENDDO

lcResult = STRTRAN(lcResult, "&"+"lt;", "<")
lcResult = STRTRAN(lcResult, "&"+"gt;", ">")
lcResult = STRTRAN(lcResult, "&"+"amp;", "&")
lcResult = STRTRAN(lcResult, "&"+"quot;", '"')

RETURN lcResult

FUNCTION HEX2TXT
LPARAMETERS lcHex

LOCAL lcStr
lcStr = "0h" + lcHex

RETURN "" + &lcStr

Open in new window

0
 

Author Closing Comment

by:esak2000
ID: 34952634
Thank you, exactly what I was looking for
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question