GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸŽ€ GOLF(2gg) β€” the encode-hex page, bestie edition πŸŽ€

okay so you're in the 2gg manual (the GOLF one, yeah, that Development corner of the docs) and you clicked on encode-hex. buckle up, this one's short and sweet. πŸ’–


✨ NAME ✨

encode-hex β€” (hex-encoding)

πŸ’… PURPOSE πŸ’…

Encode data into a hexadecimal string. that's it. that's the whole job. no cap. ✨

πŸ¦‹ SYNTAX πŸ¦‹

encode-hex <data> to <output> \
    [ input-length <input length> ] \
    [ prefix <prefix> ]

🌸 DESCRIPTION 🌸

so encode-hex takes your string <data> and encodes it into a hexadecimal string <output>. the <output> lives in the "to" clause, and it's made up of digits "0"-"9" and letters "a"-"f". that's the hex alphabet, periodt. πŸ’œ

now, how much of <data> actually gets encoded? you get to decide with the "input-length" clause β€” drop a number in as <input length> and that's how many characters get encoded. and if you don't say anything? then the whole entire string <data> is used. main character energy, it uses everything. 🫢

and ooh, if you want your output to have a little something in front of it, there's the "prefix" clause β€” put your string <prefix> there and it gets prepended to the output. if you don't bother with the clause at all, nothing gets prepended. no prefix, no problem. ✨

πŸ”₯ EXAMPLES πŸ”₯

ok so here's the vibe: we're making a hexadecimal string from binary data "mydata" that's 7 long, and we're prefixing it with the string "\\ex" β€” which is typically what you need for PostgreSQL binary input to queries, iykyk. the output string "hexout" gets created:

set-string mydata = "\x00""A""\x00""\xF""AB""\x00""\x04"
encode-hex mydata to hexout input-length 7 prefix "\\ex"

and the value of "hexout" will be:

\ex0041000F414200

ate. πŸ‘‘

πŸ‘‘ SEE ALSO πŸ‘‘

  • Hex encoding
  • decode-hex
  • encode-hex
  • See all documentation

bestie reminder: <output> is hex only β€” digits "0"-"9" and letters "a"-"f", nothing else. keep it cute, keep it hex. πŸ’…

that's the whole page, babe β€” this was GOLF(2gg), dated $DATE, version $VERSION. go forth and hex-encode, you gorgeous nerd. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from