[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: case-insensitive string comparison
From: |
Sam Steingold |
Subject: |
Re: case-insensitive string comparison |
Date: |
Tue, 19 Jul 2022 18:47:14 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin) |
> * Roland Winkler <jvaxyre@tah.bet> [2022-07-19 14:39:32 -0500]:
>
> On Tue, Jul 19 2022, Sam Steingold wrote:
>> Specifically, I would like to add
>>
>> (defun string-equal-ignore-case (s1 s2)
>> "Like `string-equal', but case-insensitive.
>> Upper-case and lower-case letters are treated as equal.
>> Unibyte strings are converted to multibyte for comparison."
>> (eq t (compare-strings s1 0 nil s2 0 nil t)))
>>
>> to subr.el next to `string-prefix-p' - is this okay?
>
> I have run into this problem fairly often that I needed case-insensitive
> string comparison, and I believe various elisp packages include a
> "private" version of the above. I always felt that
> `(eq t (compare-strings s1 0 nil s2 0 nil t))' was a crutch for this
> common problem. Would it make sense to give the built-in function
> string-equal an optional arg ignore-case?
No, because I need to be able to pass `string-equal-ignore-case' to
things like `cl-find' as `:test' &c.
Also, if you look at fns.c, `string-equal' is basically `memcmp', while
`compare-strings' is way more complex.
PS. Actually, compare-strings/ignore_case is broken because it does,
essentially, upcase both arguments, see
https://stackoverflow.com/q/319426/850781
--
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://www.dhimmitude.org http://think-israel.org
A poet who reads his verse in public may have other nasty habits.
Re: case-insensitive string comparison, Stefan Kangas, 2022/07/19
Re: case-insensitive string comparison, Roland Winkler, 2022/07/19
- Re: case-insensitive string comparison,
Sam Steingold <=
- Re: case-insensitive string comparison, Roland Winkler, 2022/07/19
- Re: case-insensitive string comparison, Stefan Monnier, 2022/07/19
- Re: case-insensitive string comparison, Sam Steingold, 2022/07/20
- Re: case-insensitive string comparison, Sam Steingold, 2022/07/25
- Re: case-insensitive string comparison, Eli Zaretskii, 2022/07/25
- Re: case-insensitive string comparison, Sam Steingold, 2022/07/25
- Re: case-insensitive string comparison, Eli Zaretskii, 2022/07/26
- Re: case-insensitive string comparison, Sam Steingold, 2022/07/26
- Re: case-insensitive string comparison, Eli Zaretskii, 2022/07/26
- Re: case-insensitive string comparison, Sam Steingold, 2022/07/26