How to resolve the algorithm URL encoding step by step in the BBC BASIC programming language
How to resolve the algorithm URL encoding step by step in the BBC BASIC programming language
Table of Contents
Problem Statement
Provide a function or mechanism to convert a provided string into URL encoding representation. In URL encoding, special characters, control characters and extended characters are converted into a percent symbol followed by a two digit hexadecimal code, So a space character encodes into %20 within the string. For the purposes of this task, every character except 0-9, A-Z and a-z requires conversion, so the following characters all require conversion by default:
The string "http://foo bar/" would be encoded as "http%3A%2F%2Ffoo%20bar%2F".
It is permissible to use an exception string (containing a set of symbols that do not need to be converted). However, this is an optional feature and is not a requirement of this task.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm URL encoding step by step in the BBC BASIC programming language
Source code in the bbc programming language
PRINT FNurlencode("http://foo bar/")
END
DEF FNurlencode(url$)
LOCAL c%, i%
WHILE i% < LEN(url$)
i% += 1
c% = ASCMID$(url$, i%)
IF c%<&30 OR c%>&7A OR c%>&39 AND c%<&41 OR c%>&5A AND c%<&61 THEN
url$ = LEFT$(url$,i%-1) + "%" + RIGHT$("0"+STR$~c%,2) + MID$(url$,i%+1)
ENDIF
ENDWHILE
= url$
You may also check:How to resolve the algorithm Wireworld step by step in the PHP programming language
You may also check:How to resolve the algorithm One of n lines in a file step by step in the BASIC programming language
You may also check:How to resolve the algorithm Least common multiple step by step in the Fortran programming language
You may also check:How to resolve the algorithm Peaceful chess queen armies step by step in the D programming language
You may also check:How to resolve the algorithm Sleep step by step in the Oforth programming language