This is the mail archive of the libc-alpha@sources.redhat.com 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]

[RFH] Trouble with mbsrtowcs and "\244" (Euro symbol)


Hi,

working on libstdc++v3 monetary facets with Benjamin (Kosnik) we are 
having trouble with wchar_t and non-ascii monetary symbols (see 
libstdc++/6410). Benjamin could distillate the problem to the following 
mostly "C" testcase:

#define _GNU_SOURCE 1

#include <locale.h>
#include <string.h>
#include <wchar.h>
#include <langinfo.h>
#include <malloc.h>

int main()
{
  const char* __name = "de_DE@euro";
  __locale_t __cloc = __newlocale(1 << LC_ALL, __name, 0);

  char* __old = strdup(setlocale(LC_ALL, NULL));
  setlocale(LC_ALL, __name);

  //const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);

  const char* __ccurr = "\244";

  mbstate_t __state;
  size_t __result;
  size_t __len = strlen(__ccurr);
  wchar_t* __wcs;
  if (__len)
    {
      ++__len;
      __wcs = new wchar_t[__len];
      memset(&__state, 0, sizeof(mbstate_t));
      __result = mbsrtowcs(__wcs, &__ccurr, __len, &__state);
    }
  setlocale(LC_ALL, __old);
  delete [] __wcs;
  free(__old);
}

What happens is that *__wcs turns out to be (unexpectedly to us) 6384, 
whereas __ccurr = "\243" => *__wcs == 163 and __ccurr = "\245" => *__wcs 
== 165.

What does 6384 mean?

Thanks for any help,
Paolo.

P.S. We are on glibc2.2.5, x86-Linux.



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