[RFH] EURO tweaks 2: problems with wchar_t

Paolo Carlini pcarlini@unitus.it
Sun Apr 21 02:31:00 GMT 2002

Hi again,

I hope this time my Request For Help is less stupid than the previous 
one... The char tweaks should be ok now in my local tree, but I'm still 
having troubles with the corresponding wchar_t case.

The following is a testcase corresponding to a function in v3 which 
apparently does'nt work well with \224 as the monetary symbol:


#define _GNU_SOURCE 1
#include <locale.h>
#include <langinfo.h>
#include <wchar.h>

int main()
  __locale_t    loc;

  size_t __len, __len2;
  mbstate_t __state;
  const char* __ccurr;

  wchar_t* _M_curr_symbol;
  const char*   __s = "de_DE@euro";
  loc = __newlocale(1 << LC_ALL, __s, 0);

  __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, loc);

  __len = strlen(__ccurr);
  if (__len)
      memset(&__state, 0, sizeof(mbstate_t));
      wchar_t* __wcs = (wchar_t*) malloc(sizeof(wchar_t) * __len);
      __len2 = mbsrtowcs(__wcs, &__ccurr, __len, &__state);
      _M_curr_symbol = __wcs;

  return 0;


What happens is that mbsrtowcs returns (size_t) -1 for the given __ccurr (*__ccurr = \224)

Any hints? Please let me know if you need some additional details or debugging informations.

Thanks in advance,

P.S. I'm on i686-pc-linux-gnu, stock glibc2.2.5.

More information about the Libstdc++ mailing list