From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.devel Subject: Re: case-insensitive string comparison Date: Tue, 26 Jul 2022 10:16:08 -0400 Message-ID: References: <87ilnsq4cr.fsf@gnu.org> <83o7xddw10.fsf@gnu.org> <83lesgc9ch.fsf@gnu.org> Reply-To: sds@gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8685"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin) To: emacs-devel@gnu.org, Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jul 26 16:19:03 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oGLOp-00020e-CF for ged-emacs-devel@m.gmane-mx.org; Tue, 26 Jul 2022 16:19:03 +0200 Original-Received: from localhost ([::1]:47824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGLOn-0005yX-UR for ged-emacs-devel@m.gmane-mx.org; Tue, 26 Jul 2022 10:19:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGLM8-0003oD-In for emacs-devel@gnu.org; Tue, 26 Jul 2022 10:16:20 -0400 Original-Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]:40572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGLM5-0003Eu-As; Tue, 26 Jul 2022 10:16:15 -0400 Original-Received: by mail-qt1-x833.google.com with SMTP id bz13so10488499qtb.7; Tue, 26 Jul 2022 07:16:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:in-reply-to:references:user-agent :return-receipt-to:reply-to:mail-followup-to:date:message-id :mime-version:content-transfer-encoding; bh=+VEDY5JvvAPuoofFGwWrVFXRBPix0SIimTdJokMIEG0=; b=T6oJwDvSAO7wEVuKsW+4xgr67jiez2j4vUf/tn5WHjOCWj1Hm3mR+XjSJMNHBUy70z h8KBEd6jbq6yfTw3Auz17nV8JBL77a4VGiEORODZ8itF5O6siOjJPfNGJrZgyMNbd3/o L4PBT7ZCV4OoUiJwC3wBvOIGHOBkBbKCUqDsXuWLEWhrn7n/nxR+QkNreRXVVHRurraw xI0QnfJRELByAd5d6Bcr5+VxoLg0xuWl2q6YjnFJ/4ihV1neYf0nT9VWgzu0cPmAOw4Y kyAN5u+NC/+CKQm9g9EhgJtFNStuKxqB+RAbWKROoQymF9PjPv0JevWfwpeMaI7jGLTP IOhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:in-reply-to:references :user-agent:return-receipt-to:reply-to:mail-followup-to:date :message-id:mime-version:content-transfer-encoding; bh=+VEDY5JvvAPuoofFGwWrVFXRBPix0SIimTdJokMIEG0=; b=Znb4aqNAOnN8VGb6xyZcWAgjObXEUWZi6Jjq70x5YRBHHfi8fn+8WgDE9RW3EeH6ti irHFhNaKou1mYBRhlckHTRLuAw0O2WvIHfrr0VuOCaklhAaSAncbiFUjAHu5WdjBrFZj AF2xcVBiW4/GcnA/E7xfRVQEl6HgX1GfmGu5jSXysn3a+ZKRhaTsHkigfz89KfaCTrLE VxwU1/w+wKxKw3WOc6zjJPLR9vz5RHrh8j26wRNH04V+lPBhftSZy/Kggk2UWtejZTID fQRIWfVbOfmYViM46lG4A8aFZDonY2ssNhZlv+FRiX21gW+fHtHNHtphhz3gCYB438b6 Tv5w== X-Gm-Message-State: AJIora+Amv6Vvpn1JSba+gM20swRwhEfyMQWR8KPROZla8jisM9I+3lP 8qL/CqE/ealTyRFLmUFVwFmxgmOmgQ== X-Google-Smtp-Source: AGRyM1t/rkLghI2VFe1odZuWnrV3zIcELnPakQeRnrurx+fDGQ0ccJ8875YG6sSaV5hZOZkNcLV1pg== X-Received: by 2002:ac8:7d4d:0:b0:31e:cd08:dbf7 with SMTP id h13-20020ac87d4d000000b0031ecd08dbf7mr14501100qtb.61.1658844970083; Tue, 26 Jul 2022 07:16:10 -0700 (PDT) Original-Received: from 3c22fb11fdab.ant.amazon.com (pool-108-30-23-113.nycmny.fios.verizon.net. [108.30.23.113]) by smtp.gmail.com with ESMTPSA id bp20-20020a05620a459400b006b5f9b7ac87sm11439446qkb.26.2022.07.26.07.16.09 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 07:16:09 -0700 (PDT) In-Reply-To: <83lesgc9ch.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 26 Jul 2022 16:05:50 +0300") X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. Mail-Followup-To: emacs-devel@gnu.org, Eli Zaretskii Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=sam.steingold@gmail.com; helo=mail-qt1-x833.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:292691 Archived-At: > * Eli Zaretskii [2022-07-26 16:05:50 +0300]: > >> From: Sam Steingold >> Date: Mon, 25 Jul 2022 15:39:34 -0400 >>=20 >> > * Eli Zaretskii [2022-07-25 18:58:19 +0300]: >> > >> >> > (string-collate-equalp "a" "A" current-locale-environment t) >> >> > =3D=3D> nil >> >> > current-locale-environment >> >> > =3D=3D> "en_US.UTF-8" >> > >> > I cannot reproduce this: >> > >> > (string-collate-equalp "a" "A" current-locale-environment t) >> > =3D> t >> > current-locale-environment >> > =3D> "en_US.UTF-8" >> > >> > What OS is this, and which Emacs version? >>=20 >> GNU Emacs 29.0.50 (build 5, x86_64-apple-darwin21.5.0, NS appkit-2113.50= Version 12.4 (Build 21F79)) >> of 2022-07-25 >> Repository revision: ffe12ff2503917e47c0356195b31430996c148f9 >> Repository branch: master >> Windowing system distributor 'Apple', version 10.3.2113 >> System Description: macOS 12.4 > > Could be something macOS-specific. Maybe your system doesn't define > the __STDC_ISO_10646__ feature? In that case, string-collate-equalp > (see the doc string) behaves like string-equal, and that one doesn't > have a case-insensitive variant. How do I find out? --8<---------------cut here---------------start------------->8--- echo > .zzz.c; gcc -E -dM .zzz.c | grep __STDC_ISO_10646__ --8<---------------cut here---------------end--------------->8--- does not print anything, but maybe I need to `#include' something? > In general, locale-specific comparison is a bad idea in Emacs... > For that reason, I suggest always using compare-strings instead. Thank you very much for the clear and detailed explanation! >> >> It is okay to add a `string-equal-ignore-case' based on `compare-stri= ngs'? >> >> (even though it does not recognize "SS" and "=C3=9F" as equal) >> > >> > What's wrong with calling compare-strings directly? >> >> I want to be able to use `string-equal-ignore-case' as a :test argument >> to things like `cl-find'. > > Then write a thin wrapper around compare-strings, and be done. I think the need is sufficiently generic, e.g., BBDB provides such a wrapper, as, I am sure, do many other packages. Many core files can be simplified by using `string-equal-ignore-case' (just like with the `string-prefix-p'). Thank again! --=20 Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.2113 http://childpsy.net http://calmchildstories.com http://steingoldpsychology.= com https://www.dhimmitude.org https://thereligionofpeace.com When you are arguing with an idiot, your opponent is doing the same.