public inbox for libc-locales@sourceware.org
 help / color / mirror / Atom feed
* [Bug localedata/14257] New: setlocale(LC_CTYPE, NULL) causes undesired side effects
@ 2012-06-16 17:38 siteshwar at gmail dot com
  2012-06-16 17:49 ` [Bug localedata/14257] " schwab@linux-m68k.org
  2014-06-18  5:17 ` fweimer at redhat dot com
  0 siblings, 2 replies; 3+ messages in thread
From: siteshwar at gmail dot com @ 2012-06-16 17:38 UTC (permalink / raw)
  To: libc-locales

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug localedata/14257] setlocale(LC_CTYPE, NULL) causes undesired side effects
  2012-06-16 17:38 [Bug localedata/14257] New: setlocale(LC_CTYPE, NULL) causes undesired side effects siteshwar at gmail dot com
@ 2012-06-16 17:49 ` schwab@linux-m68k.org
  2014-06-18  5:17 ` fweimer at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: schwab@linux-m68k.org @ 2012-06-16 17:49 UTC (permalink / raw)
  To: libc-locales

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

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> 2012-06-16 17:47:41 UTC ---
This has nothing to do with setlocale.  You are mixing char with wide char I/O
on the same stream (printf vs. putwc).  The first output makes the orientation
permanent until the stream is closed.

-- 
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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug localedata/14257] setlocale(LC_CTYPE, NULL) causes undesired side effects
  2012-06-16 17:38 [Bug localedata/14257] New: setlocale(LC_CTYPE, NULL) causes undesired side effects siteshwar at gmail dot com
  2012-06-16 17:49 ` [Bug localedata/14257] " schwab@linux-m68k.org
@ 2014-06-18  5:17 ` fweimer at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: fweimer at redhat dot com @ 2014-06-18  5:17 UTC (permalink / raw)
  To: libc-locales

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

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-18  5:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-16 17:38 [Bug localedata/14257] New: setlocale(LC_CTYPE, NULL) causes undesired side effects siteshwar at gmail dot com
2012-06-16 17:49 ` [Bug localedata/14257] " schwab@linux-m68k.org
2014-06-18  5:17 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).