Deutsch English Français Italiano |
<slrnv069hn.tsn.naddy@lorvorc.mips.inka.de> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail From: Christian Weisgerber <naddy@mips.inka.de> Newsgroups: comp.unix.bsd.freebsd.misc Subject: Re: locale/LC_CTYPE vs strcasecmp? Date: Tue, 26 Mar 2024 19:47:03 -0000 (UTC) Message-ID: <slrnv069hn.tsn.naddy@lorvorc.mips.inka.de> References: <ydfrwdgujk.fsf@UBEblock.psr.com> Injection-Date: Tue, 26 Mar 2024 19:47:03 -0000 (UTC) Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1"; logging-data="30616"; mail-complaints-to="usenet@mips.inka.de" User-Agent: slrn/1.0.3 (FreeBSD) Bytes: 1535 Lines: 24 On 2024-03-26, Winston <wbe@UBEBLOCK.psr.com.invalid> wrote: > The man page says strcasecmp_l() takes an explicit locale. > The implication is that strcasecmp() uses the current locale > (presumably as set by setlocale()). Yes. src/lib/libc/string/strcasecmp.c: 57 int 58 strcasecmp(const char *s1, const char *s2) 59 { 60 return strcasecmp_l(s1, s2, __get_locale()); 61 } > After calling setlocale(LC_ALL, "uk_UA.UTF-8"), I'm seeing that > strcasecmp() is not, in fact, case-independently matching non-ASCII > UTF-8 strings: it's case sensitive (the ASCII equivalent in this > case being that "Abc" isn't matching "abc"). UTF-8 characters are multibyte. You need to convert the strings to wide characters and use wcscasecmp(). -- Christian "naddy" Weisgerber naddy@mips.inka.de