URL encoding: Difference between revisions
no edit summary
(Applesoft BASIC) |
No edit summary |
||
Line 658:
http%3A%2F%2Ffoo+bar%2F
</pre>
=={{header|FutureBasic}}==
<pre>
In addition to the generic alphanumeric character set used in the demo code below, FB offers several special character sets for URL encoding:
fn CharacterSetURLFragmentAllowedSet
fn CharacterSetURLHostAllowedSet
fn CharacterSetURLPasswordAllowedSet
fn CharacterSetURLPathAllowedSet
fn CharacterSetURLQueryAllowedSet
fn CharacterSetURLUserAllowedSet
Users can also create custom character strings with:
fn CharacterSetWithCharactersInString( CFStringRef string ) = CFCharacterSetRef
</pre>
<syntaxhighlight lang="futurebasic">
include "NSLog.incl"
local fn PercentEncodeURLString( urlStr as CFStringRef ) as CFStringRef
CFStringRef encodedStr = fn StringByAddingPercentEncodingWithAllowedCharacters( urlStr, fn CharacterSetAlphanumericSet )
end fn = encodedStr
NSLog( @"%@", fn PercentEncodeURLString( @"http://foo bar/" ) )
NSLog( @"%@", fn PercentEncodeURLString( @"http://www.rosettacode.org/wiki/URL_encoding" ) )
HandleEvents
</syntaxhighlight>
{{out}}
<pre>
http%3A%2F%2Ffoo%20bar%2F
http%3A%2F%2Fwww%2Erosettacode%2Eorg%2Fwiki%2FURL%5Fencoding
</pre>
=={{header|Go}}==
Line 674 ⟶ 710:
http%3A%2F%2Ffoo+bar%2F
</pre>
=={{header|Groovy}}==
|