NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/57339: towupper and towlower malfunction in zh_CN.GB18030 locale



>Number:         57339
>Category:       lib
>Synopsis:       towupper and towlower malfunction in zh_CN.GB18030 locale
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 09 21:25:00 +0000 2023
>Originator:     Bruno Haible
>Release:        9.0
>Organization:
GNU
>Environment:
NetBSD 9.0 amd64
>Description:
In the zh_CN.GB18030 locale, the towupper and towupper functions map the ASCII letters (A..Z, a..z) in a nonsensical way.

>How-To-Repeat:
Compile and run this program:
=============================================================
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>

/* towlower and towupper are botched in the zh_CN.GB18030 locale. */

int main ()
{
  if (setlocale (LC_ALL, "zh_CN.GB18030") == NULL)
    return 1;

  int result = 0;
  wchar_t ua = btowc ('A');
  wchar_t la = btowc ('a');
  if (towupper (ua) != ua) {
    printf ("towupper (%lc) -> %lc\n", ua, towupper (ua));
    result |= 2;
  }
  if (towupper (la) != ua) {
    printf ("towupper (%lc) -> %lc\n", la, towupper (la));
    result |= 4;
  }
  if (towlower (ua) != la) {
    printf ("towlower (%lc) -> %lc\n", ua, towlower (ua));
    result |= 8;
  }
  if (towlower (la) != la) {
    printf ("towlower (%lc) -> %lc\n", la, towlower (la));
    result |= 16;
  }

  return result;
}
=============================================================
Expected result: no output.
Actual result:
towupper (A) -> a
towupper (a) -> a
towlower (A) -> A
towlower (a) -> A

>Fix:



Home | Main Index | Thread Index | Old Index