This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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]

Re: [BUG] wprintf(L"%s", str) expects str to be wide


Corinna:
It appears, taking a quick glance at the source, that the string is only treated as regular characters if _MB_CAPABLE is defined--otherwise it falls into a wide-character-only case. This could perhaps explain the differing results.
Craig


On 01/11/2013 03:13 AM, Corinna Vinschen wrote:
On Jan 10 22:58, Konstantin Isakov wrote:
Hi,

This works as expected in glibc:

#include<stdio.h>
wprintf(L"Hello, %s\n", "world");

However, the same thing does not work correctly in newlib. Instead, this works:

wprintf(L"Hello, %s\n", L"world");
Works as expected for me on Cygwin:

   $ cat>  wp.c<<EOF
   #include<stdio.h>

   int
   main ()
   {
     wprintf(L"Hello 1, %s\n", "world");
     wprintf(L"Hello 2, %s\n", L"world");
     wprintf(L"Hello 3, %ls\n", L"world");
     return 0;
   }
   EOF
   $ gcc -g -o wp wp.c
   $ ./wp
   Hello 1, world
   Hello 2, w
   Hello 3, world


Corinna




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