mysql_hex_string(3)
β¨ 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 thatfromstring, gotta know how much we're working with
π NOTES π
- The buffer you make for the encoded string must be
2 * length + 1in 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 π
mysql_real_escape_string(3)β her sister, also iconic, also does escaping
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
- alpine 3.22: mariadb-doc 11.4.13-r0 Β· GPL-2.0-or-later
- alpine 3.23: mariadb-doc 11.4.13-r0 Β· GPL-2.0-or-later
- alpine 3.24: mariadb-doc 11.8.9-r0 Β· GPL-2.0-only
- arch rolling: mariadb 13.0.2-2 Β· GPL-2.0-only
- arch rolling: mariadb-lts 12.3.3-2 Β· GPL-2.0-only
- centos-stream 10: mariadb-connector-c-doc 3.4.4-2.el10 Β· LGPL-2.1-or-later
- debian trixie: libmariadb-dev 1:11.8.6-0+deb13u1 Β· GPL-2.0-only
- fedora 43: mariadb-connector-c-doc 3.4.5-2.fc43 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01
- fedora 43: mariadb-connector-c-doc 3.4.9-2.fc43 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01 AND LicenseRef-Fedora-Public-Domain
- fedora 44: mariadb-connector-c-doc 3.4.8-3.fc44 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01
- fedora 44: mariadb-connector-c-doc 3.4.9-2.fc44 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01 AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: mariadb-server 11.8.8
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- ubuntu questing: libmariadb-dev 1:11.8.3-1build1
- ubuntu resolute: libmariadb-dev 1:11.8.6-5 Β· GPL-2.0-only
- ubuntu resolute: libmariadb-dev 1:11.8.6-5ubuntu0.1 Β· GPL-2.0-only
- ubuntu stonking: libmariadb-dev 1:11.8.9+ds-4ubuntu2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms