OPENSSL_STRCASECMP(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

πŸ’– OPENSSL_STRCASECMP πŸ’–

okay so bestie, this is the OPENSSL_STRCASECMP(3ossl) page from the OpenSSL manual, and we're about to make case-insensitive string comparison your whole personality. stay with me, it's gonna slay ✨


🌸 NAME 🌸

OPENSSL_strcasecmp, OPENSSL_strncasecmp β€” the girlies that compare two strings while fully ignoring case, no cap πŸ’…


πŸŽ€ 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);

πŸ¦‹ DESCRIPTION πŸ¦‹

so OPENSSL_strcasecmp does a byte-by-byte comparison of the strings s1 and s2, and the entire time it's ignoring the case of the characters. like, uppercase, lowercase, whatever β€” it does not care, it's not the vibe πŸ‘‘

OPENSSL_strncasecmp is the exact same energy, except it compares no more than n bytes of s1 and s2. so it's got boundaries. iconic.

now here's the tea on locales β˜• β€” in a POSIX-compatible system and on Windows, these functions use the "C" locale for case insensitivity. otherwise? the comparison is done in the current locale. so like, know which one you're in, iykyk πŸ™ˆ


🫢 RETURN VALUES 🫢

both functions return an integer that's either:

  • less than zero if s1 is found to be less than s2 πŸ’€
  • equal to zero if s1 matches s2 πŸ’–
  • greater than zero if s1 is found to be greater than s2 πŸ”₯

periodt, that's the whole return story.


⭐ NOTES ⭐

OpenSSL extensively uses case-insensitive comparison of ASCII strings. lots of it. constantly. it's a whole thing.

and here's where it gets messy 😭 β€” even though OpenSSL itself is locale-agnostic, applications that use OpenSSL libraries may unpredictably suffer when they use localization. the classic example? the Turkish locale, which is famously known for its specific I/i cases. yeah. that one. 🫠

so these functions use the C locale for string comparison. safety first, bestie.


🌈 HISTORY 🌈

these functions were added in OpenSSL 3.0.3. so they're not ancient, they're just well-adjusted ✨


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>.


πŸ’œ fr fr, read the license before you go copying stuff. it's giving legal, but make it cute.

and that's the whole page, bestie β€” 3.5.6, dated 2026-04-07, from the OpenSSL manual. go compare some strings, you absolute main character πŸ§šπŸ’–

πŸ“¦ where this page comes from