Closed Bug 70740 Opened 24 years ago Closed 23 years ago

case-insensitive string comparison for nsAReadableString

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla0.9

People

(Reporter: dbaron, Assigned: scc)

References

Details

Attachments

(1 file)

It would be nice to have some way to do case-insensitive string comparison on an
nsAReadableString.  Right now, AFAICT, the only ways to do it are through nsCRT
(on char* or PRUnichar*) or through nsString::EqualsIgnoreCase.  This means that
if one wants to do a case-insensitive comparison of a substring of one
nsAReadableString to all of another, one must copy the substring.  A good
example of where this would be useful is bug 70734.
*** Bug 48853 has been marked as a duplicate of this bug. ***
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9
Blocks: 28221
sr=sfraser
r=mjudge
fix checked in
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
This was only for the ASCII subset of Unicode I guess?
The fix I checked in allowed clients to specify a comparator, a la

  Compare(a, b, nsCaseInsensitiveStringComparator())

The specific comparator I mention above uses |nsCRT::strncasecmp| to compare
actual hunks, but you can supply your own if you have a more specific desire.
|strncasecmp| is the existing behavior for case insensitive comparisons (i.e.,
what |nsString| supplied before).  It's original rickg code.  It _looks_ to me
like it only works in the iso latin 1 subset (at least that's what the naming
leads me to believe); but you are free to provide your own comparator if this
isn't sufficient.
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: