This is the mail archive of the
libc-locales@sourceware.org
mailing list for the GNU libc locales project.
[Bug localedata/14257] New: setlocale(LC_CTYPE, NULL) causesundesired side effects
- From: "siteshwar at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: libc-locales at sources dot redhat dot com
- Date: Sat, 16 Jun 2012 17:35:13 +0000
- Subject: [Bug localedata/14257] New: setlocale(LC_CTYPE, NULL) causesundesired side effects
- Auto-submitted: auto-generated
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.