Project

General

Profile

Actions

Bug #15816

closed

String#casecmp compares uppercase characters instead of lowercase

Added by jonathanhefner (Jonathan Hefner) about 5 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:92520]

Description

The current implementation of String#casecmp converts characters to uppercase before comparing them. However, all references I've found for strcasecmp (the C function on which String#casecmp is based) indicate characters should be converted to lowercase before being compared.

For example, this man page says:

The POSIX.1-2008 standard says ... shall behave as if the strings had been converted to lowercase and then a byte comparison performed.

The difference in behavior is apparent when comparing / sorting strings containing [, \, ], ^, _, or ` (the characters that occur between Z and a). Converting to lowercase sorts these punctuation characters before A-z along with most of the other punctuation in ASCII, but converting to uppercase sorts these characters after A-z instead.


Files

casecmp-lowercase.patch (1.3 KB) casecmp-lowercase.patch jeremyevans0 (Jeremy Evans), 05/09/2019 03:37 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0