This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug localedata/14257] New: setlocale(LC_CTYPE, NULL) causes undesired side effects


http://sourceware.org/bugzilla/show_bug.cgi?id=14257

             Bug #: 14257
           Summary: setlocale(LC_CTYPE, NULL) causes undesired side
                    effects
           Product: glibc
           Version: 2.14
            Status: NEW
          Severity: normal
          Priority: P2
         Component: localedata
        AssignedTo: unassigned@sourceware.org
        ReportedBy: siteshwar@gmail.com
                CC: libc-locales@sources.redhat.com
    Classification: Unclassified


I have written following program to reproduce side effect :

#include <stdio.h>
#include <wchar.h>
#include <locale.h>

int main()
{
    setlocale(LC_ALL,"");


    //This will cause side effect
    const char * c = setlocale(LC_CTYPE, NULL);
    printf("%s\n", c);


    while (!feof(stdin))
    {
        wint_t t = fgetwc(stdin);
        wchar_t t1 = static_cast<wchar_t>(t);

        putwc(t1, stdout);
    }
}

When I try to input unicode characters I get garbage characters in output.

[situ@juggernaut bugs]$  ./a.out 
æè
Kï


If I remove call to setlocale(LC_CTYPE, NULL) output is fine.

[situ@juggernaut bugs]$  ./a.out 
æè
æè

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]