User Tools

Site Tools


mmbasic:url_decode_function

URL DECODE Function

Decodes the query part of a URL string. URL encoding is used when placing text in a query string to avoid it being confused with the URL itself. It is normally used when the browser sends form data to a web server as part of the URI - as part of the “web address” (GET method).

Syntax:

  URLDecode$(expression)

Example:

  realURL$=URLDecode$(RecdURL)

Code:

  FUNCTION URLDecode$(a$)
    LOCAL INTEGER z
    LOCAL STRING b$,c$
    z=1
    DO
      z=INSTR(z,a$,"%")
      IF z=0 OR z=LEN(a$) THEN EXIT DO
        b$=MID$(a$,z,3)
        c$=CHR$(VAL("&h"+MID$(b$,2)))
        a$=Replace$(a$,b$,c$)
      END IF
    LOOP
    URLDecode$=a$
  END FUNCTION
mmbasic/url_decode_function.txt · Last modified: 2024/01/19 09:30 by 127.0.0.1