OPENSSL_STRCASECMP(3SSL)
β¨ OPENSSL_STRCASECMP π
okay bestie, we're in the OpenSSL manual, section 3SSL, and today's main characters are OPENSSL_strcasecmp and OPENSSL_strncasecmp β two little functions that compare strings while β¨ignoring caseβ¨. no cap, that's literally the whole plot.
πΈ SYNOPSIS πΈ
#include <openssl/crypto.h>
int OPENSSL_strcasecmp(const char *s1, const char *s2);
int OPENSSL_strncasecmp(const char *s1, const char *s2, size_t n);
like, that's it. two function signatures. so clean. so demure. π
π¦ DESCRIPTION π¦
okay so. OPENSSL_strcasecmp does a byte-by-byte comparison of the strings s1 and s2, and it just... doesn't care about the case of the characters. uppercase, lowercase, who cares, it's giving unbothered queen. π
OPENSSL_strncasecmp is the same vibe, except it compares no more than n bytes of s1 and s2. so it stops early, periodt.
now here's the tea on how the case-insensitivity actually works π« β on a POSIX-compatible system and on Windows, these functions use the "C" locale for case insensitive comparison. Otherwise, the comparison is done in the current locale. iykyk.
π RETURN VALUES π
both functions hand you back an integer, and it goes like this:
- less than zero if
s1is found to be less thans2 - equal to zero if
s1matchess2 - greater than zero if
s1is found to be greater thans2
that's the whole vibe check. negative, zero, positive. slay. β
π NOTES π
OpenSSL extensively uses case insensitive comparison of ASCII strings. like, it's everywhere. main character behaviour fr fr.
but listen β even though OpenSSL itself is locale-agnostic, the applications using OpenSSL libraries may unpredictably suffer when they use localization. and the iconic example? the Turkish locale, which is well-known for having a specific I/i situation. π your app could just start acting different and you'd have no idea why.
so these functions use the C locale for string comparison. that's the safety net bestie, don't fight it.
π HISTORY π
these functions were added in OpenSSL 3.0.3. so if you're on something older, they simply do not exist yet, and that's a whole different problem. π
π COPYRIGHT π
Copyright 2022-2024 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the page, bestie π«Ά this was version 4.0.3, dated 2026-09-29, from the OPENSSL_STRCASECMP(3SSL) manual β read it, love it, go compare some strings. bye!! π πβ¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms