mysql_hex_string(3)

πŸ“¦
version 13.0.2 Β· 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

mysql_hex_string β€” bestie, it makes you a hexadecimal string πŸ’…

So like, this page is mysql_hex_string(3) from the MariaDB Connector/C manual, and we're gonna get you fluent in it, no cap.


🌸 SYNOPSIS 🌸

#include <mysql.h>
unsigned long mysql_hex_string(char * to,
                               const char * from,
                               unsigned long len);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so picture this: you need a hex string you can literally drop straight into a SQL statement. That's the whole gig. It's giving "encode my bytes so the database doesn't get confused."

Like, for example:

INSERT INTO my_blob VALUES(X'A0E1CD')

That's the vibe. mysql_hex_string is the girl who hands you the A0E1CD part. πŸŽ€


πŸ’– PARAMETER πŸ’–

  • to β€” your result buffer, aka where the glow-up gets written ✨
  • from β€” the string that's getting encoded, the raw material, the before pic πŸ“Έ
  • len β€” the length of that from string, gotta know how much we're working with

πŸ‘‘ NOTES πŸ‘‘

  • The buffer you make for the encoded string must be 2 * length + 1 in size. Not negotiable, bestie, do the math and give it room to breathe 🫢
  • The encoded string does not contain a leading X'. You get the bare hex, you add the dressing yourself πŸ’…

⭐ RETURN VALUE ⭐

It returns the length of the encoded string, and that's without the trailing null character. So don't come for the null, she's not in the count πŸ™ˆ


🌈 SEE ALSO 🌈


Okay that's the whole page, mwah πŸ’œ Sending you off with the official receipts: this was Version 3.4, and yes, she's mysql_hex_string(3), still the moment, still serving. Go hex something, you absolute legend πŸ‘‘βœ¨

πŸ“¦ where this page comes from