GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸ’– GOLF(2gg) πŸ’–

okay bestie, we're in the Development section of the 2gg manual and today's main character is encode-url. she's a little function, she's a baddie, and she's about to make your strings safe for URLs. let's get into it 🫢


✨ NAME ✨

encode-url β€” it's giving URL-encoding, fr fr 🌈


🎯 PURPOSE 🎯

URL-encode a string. that's it, that's the whole vibe. slay πŸ’…


🧚 SYNTAX 🧚

encode-url <string> to <encoded string> \
    [ input-length <length> ]

so you hand her a string, you tell her where to put the encoded result, and optionally you can whisper input-length in her ear. periodt ✨


🌸 DESCRIPTION 🌸

encode-url takes <string>, URL-encodes it, and drops the glow-up version into <encoded string>. literally the simplest relationship ever, no cap πŸ’œ

now about that <length> in the input-length clause β€” she lets you say exactly how many bytes of <string> should get encoded. if you don't specify it, or if you give her a negative number, she just uses the whole string length. she's flexible like that πŸ™ˆ

here's the tea on what actually gets encoded: every single byte gets the treatment except alphanumerics and the characters from "-._~" β€” that's dash, dot, underscore, and tilde. those four are the safe little icons who get to stay exactly as they are πŸ‘‘

heads up bestie: everything else? encoded. no exceptions, no mercy, that's just how she rolls πŸ’€

πŸŽ€ EXAMPLES πŸŽ€

so in this example, we have a string called "str" and we URL-encode it, and the result lands in a string variable called "result":

set-string str="  x=y?z&  "
encode-url str to result

and the "result"? she ate and left no crumbs:

"%20%20x%3Dy%3Fz%26%20%20"

see how those spaces became %20 and the =, ?, and & all got their little percent codes? iconic behavior honestly πŸ¦‹


πŸ‘€ SEE ALSO πŸ‘€

  • URL encoding 🌈
  • decode-url β€” the reverse queen, check her out πŸ’–
  • encode-url (yes, she's listing herself, main character energy πŸ‘‘)
  • See all documentation πŸ“š

okay that's the whole page, you're officially educated on encode-url πŸ’…βœ¨ this was version $VERSION, dated $DATE, and yes this absolute banger lives in the GOLF(2gg) manual. go forth and encode responsibly, bestie πŸ“πŸ’œ

πŸ“¦ where this page comes from