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:28:01 -0400 Message-ID: References: <87ilnsq4cr.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="32102"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin) Cc: Bruno Haible To: emacs-devel@gnu.org, rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jul 26 16:38:37 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 1oGLhi-00084Y-Jm for ged-emacs-devel@m.gmane-mx.org; Tue, 26 Jul 2022 16:38:34 +0200 Original-Received: from localhost ([::1]:38578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGLhh-0002uZ-It for ged-emacs-devel@m.gmane-mx.org; Tue, 26 Jul 2022 10:38:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGLXa-0004cu-NT for emacs-devel@gnu.org; Tue, 26 Jul 2022 10:28:08 -0400 Original-Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]:46673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGLXY-0004xR-Q6; Tue, 26 Jul 2022 10:28:06 -0400 Original-Received: by mail-qt1-x82a.google.com with SMTP id x11so10490644qts.13; Tue, 26 Jul 2022 07:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:in-reply-to:references:user-agent :return-receipt-to:reply-to:mail-followup-to:date:message-id :mime-version:content-transfer-encoding; bh=9Tl5lDVjRy5apD/Yjr71g+57xWtrGH4N13F2yl6VoHI=; b=DuWbtOCWW1kXAwbe1/7EW0MzCtoN8DogXE/1RzbjanBvNSeki9rSDjHN9Wtb6Op7UN +gEhoA8g1LamQssG10pZogri2CPWcQoGSnIVQnTEn+K7g/2EoH9Bh+me2Wv4zxNPbWCb /qy4nNLkOD0fYyk+1to6XERkrnWpezgLiDFM7KPWeULsEf6BQl8kScu1lJx/J9skTTr6 AuzYuhkKaT7KzAULHecE/OSYyoV9BvqdkjSRtPJUEh5HsqYqgg+misV61k9A4SXbBQZe Dyx8CuIetsgpWNupD6i4ilIpAsplQPzRey6a4OnujVuREUmTcWs7a9uUtQPRzyoeTbmY X1mw== 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:cc:subject:in-reply-to:references :user-agent:return-receipt-to:reply-to:mail-followup-to:date :message-id:mime-version:content-transfer-encoding; bh=9Tl5lDVjRy5apD/Yjr71g+57xWtrGH4N13F2yl6VoHI=; b=Yr9329PArpV5h5kCj4jvbzboffq7guI73VPP0fIxNfZCgqYuHeyvsgCVheMgpqQHEn QBGhdvzYzuBuWlVc6FgGTkKmVNbFTyzqrut9u3dbrP84ghGmlRUlbcWrKEVHayyl68co mskYOQWTIGoARR0I0adIBgITggNL8xbnHYAtRfDO0nF226ZT7YOTTTkNCw+2g+DA977t 6uSCT3WQPPs253TJE42t6rig1DyPiU1yjGRjie7IgB/949o8WdHGMy+vlIf1LvfIhhzW y/ltfPiws/Vc41M1ZNDDAj2YKRYFoJK8BG8vSjculInbgJaQM1jlRNgIvZEUuV7mmTaU WaHg== X-Gm-Message-State: AJIora8K/Qgh1E/u2ckhZkj4cTI9J7MwHMmunDxNKqa9jysgN1qUImDF 7QDtZk2Pe+oADJHGXXyssC9jtihQAg== X-Google-Smtp-Source: AGRyM1vw7/PNEmRP7z7lYItYwYCa1L1S7bovMG4mC2xUP/T/xHfxPaKp86VglKH8G1n5YEZU9XLjaQ== X-Received: by 2002:ac8:5c03:0:b0:31f:1bef:1915 with SMTP id i3-20020ac85c03000000b0031f1bef1915mr14423218qti.26.1658845682340; Tue, 26 Jul 2022 07:28:02 -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 bp40-20020a05620a45a800b006a793bde241sm11812258qkb.63.2022.07.26.07.28.01 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 07:28:01 -0700 (PDT) In-Reply-To: (Richard Stallman's message of "Mon, 25 Jul 2022 23:24:43 -0400") X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. Mail-Followup-To: emacs-devel@gnu.org, rms@gnu.org, Bruno Haible Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=sam.steingold@gmail.com; helo=mail-qt1-x82a.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:292693 Archived-At: > * Richard Stallman [2022-07-25 23:24:43 -0400]: > > > 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) > > A function `string-equal-ignore-case' would make sense. My question is, > is it worth the cost in complexity, or is it better to urge users to call > `compare-strings' directly? 1. we already have `string-prefix-p' and `string-suffix-p' which are thin wrappers around `compare-strings' > That depends on how often programs will do case-insensitive string compar= ison. > If frequently, that gives a bigger upside to `string-equal-ignore-case'. 2. there are dozens of places in Emacs core with code like --8<---------------cut here---------------start------------->8--- (eq t (compare-strings (sgml-tag-name tag-info) nil nil (car stack) nil nil t)) --8<---------------cut here---------------end--------------->8--- 3. some emacs packages already have to define their own versions of `string-equal-ignore-case', e.g., `bbdb-string=3D'. > > Or should we first implement something like casefold in Python? > > https://docs.python.org/3/library/stdtypes.html#str.casefold > > That casefold operation is not the same thing as ignoring case in > Emacs. Normally, case-insensitive comparison means something like --8<---------------cut here---------------start------------->8--- (string=3D (casefold A) (casefold B)) --8<---------------cut here---------------end--------------->8--- `compare-strings' does --8<---------------cut here---------------start------------->8--- (string=3D (upcase A) (upcase B)) --8<---------------cut here---------------end--------------->8--- (except it does it character-by-character, no allocating new strings for `upcase'). > How to integrate something like that into Emacs, and in > general how to handle `=C3=9F' properly in case conversion, calls for more > thought. Bruno Haible replied in this thread, suggesting libunistring via gnulib. I think this is the easiest way to handle the issue. --=20 Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.2113 http://childpsy.net http://calmchildstories.com http://steingoldpsychology.= com https://memri.org https://honestreporting.com https://ffii.org The program isn't debugged until the last user is dead.