This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

[Fwd: Re: Update on libstdc++/6410 (a.k.a. non-ascii mon. symbolAND wchar_t => chaos)]


Hi all --

Benjamin intended to send the following to the list too but forgot to do 
so... Here it is. Please help!

Ciao,
Paolo.

--- Begin Message ---

> Any idea useful to make some further progress?

Here's something to think about.

Take the following, mostly "C" code:

#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);
  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);
}

Then, looking at it in gdb:
(gdb) p __ccurr
$12 = 0x4003a0c5 "¤"
(gdb) p *__ccurr
$13 = -92 '¤'

then...

(gdb) p __wcs
$14 = (wchar_t *) 0x80adc40
(gdb) p *__wcs
$15 = 8364

both of these values are perhaps unexpected.

The good news is that the C++ code in your example program gives the
same values as the above.

Thoughts?

-benjamin

--- End Message ---

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