string-downcase does not downcase character 224

Bug #2067841 reported by Matt Kaufmann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

The CL HyperSpec says (https://www.lispworks.com/documentation/HyperSpec/Body/f_stg_up.htm#string-downcase): "string-downcase is like string-upcase except that all uppercase characters are replaced by the corresponding lowercase characters (using char-downcase)." But that fails in the following example: the two results should be the same (note that they are both 224 in CCL, LispWorks, CMUCL, and Allegro CL, and they are both 192 in GCL).

    * (char-code (char-downcase (code-char 192)))
    224
    * (let ((s (string-downcase (coerce (list (code-char 192)) 'string))))
        (char-code (char s 0)))
    192
    *

Interestingly, going in the other direction (using string-upcase) works as expected.

    * (let ((s (string-upcase (coerce (list (code-char 224)) 'string))))
        (char-code (char s 0)))
    192
    *

Apparently (code-char 224) is the only standard character with this problem.

    * (loop for i from 0 to 255
            as c = (code-char i)
            when (and (lower-case-p c)
                      (let ((s (coerce (list c) 'string)))
                        (not (equal (string-downcase (string-upcase s)) s))))
            collect i)
    (224)
    *

I got the results above on MacOS using the latest SBCL:

    ~$ uname -a
    Darwin Matts-MacBook-Pro.local 19.6.0 Darwin Kernel Version 19.6.0: Tue Jun 21 21:18:39 PDT 2022; root:xnu-6153.141.66~1/RELEASE_X86_64 x86_64
    ~$ sbcl --version
    SBCL 2.4.5
    ~$

    * *features*
    (:ARENA-ALLOCATOR :X86-64 :GENCGC :64-BIT :ANSI-CL :BSD :COMMON-LISP :DARWIN
     :IEEE-FLOATING-POINT :LITTLE-ENDIAN :MACH-O :PACKAGE-LOCAL-NICKNAMES :SB-LDB
     :SB-PACKAGE-LOCKS :SB-THREAD :SB-UNICODE :SBCL :UNIX)
    *

On Linux I used the preceding SBCL version:

    cyan:~% uname -a
    Linux cyan 5.4.0-182-generic #202-Ubuntu SMP Fri Apr 26 12:29:36 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
    cyan:~% sbcl --version
    SBCL 2.4.4
    cyan:~%

    * *features*
    (:ARENA-ALLOCATOR :X86-64 :GENCGC :64-BIT :ANSI-CL :COMMON-LISP :ELF
     :IEEE-FLOATING-POINT :LINUX :LITTLE-ENDIAN :PACKAGE-LOCAL-NICKNAMES :SB-LDB
     :SB-PACKAGE-LOCKS :SB-THREAD :SB-UNICODE :SBCL :UNIX)
    *

Stas Boukarev (stassats)
Changed in sbcl:
status: New → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.