LIBRESSL-ASN1_UNIVERSALSTRING_TO_STRING(3)
β¨ ASN1_UNIVERSALSTRING_TO_STRING(3) β¨
okay bestie, so this one lives in the Library Functions Manual and it's genuinely such a slay little converter β it's giving "glow-up for your strings" π
πΈ NAME πΈ
ASN1_UNIVERSALSTRING_to_string β recode UTF-32 to ISO Latin-1
π¦ SYNOPSIS π¦
library βlibcryptoβ
#include <openssl/asn1.h>
int
ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *string);
π DESCRIPTION π
okay so here's the tea: ASN1_UNIVERSALSTRING_to_string() assumes your given string is encoded in UTF-32 β like, it's trusting you on this, no vibe check first β and then it recodes it in place to ISO Latin-1, and changes the type according to ASN1_PRINTABLE_type(3). in-place, bestie, no copy, no drama. π₯
but like, it's not gonna just manifest for you if the vibes are off π ASN1_UNIVERSALSTRING_to_string() fails and leaves the string unchanged if any of these are true:
- its
ASN1_STRING_type(3)is notV_ASN1_UNIVERSALSTRING - its
ASN1_STRING_length(3)is not a multiple of four bytes - any of its characters cannot be represented in ISO Latin-1
so yeah, three strikes and it's not touching your string at all, periodt. π
in case of success, the ASN1_STRING_length(3) of the string is reduced by a factor of four β because UTF-32 was being extra with four bytes per character and Latin-1 is out here living its simple one-byte life. iconic behavior honestly. π
π RETURN VALUES π
ASN1_UNIVERSALSTRING_to_string()returns1on success or0on failure. that's it, that's the whole story. π
π«Ά SEE ALSO π«Ά
ASN1_mbstring_copy(3), ASN1_STRING_new(3), ASN1_STRING_to_UTF8(3)
β HISTORY β
ASN1_UNIVERSALSTRING_to_string() first appeared in SSLeay 0.8.0 and has been available since OpenBSD 2.4. she's been out here thriving since the olden days, fr fr π
and that's the whole page, bestie!! this one's from the Debian build, dated June 8, 2025, and it's ASN1_UNIVERSALSTRING_TO_STRING(3) β go forth and recode responsibly β¨π§ββοΈπ
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms